Login.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <template>
  2. <div class="modal is-active">
  3. <div class="modal-background" @click="closeCurrentModal()" />
  4. <div class="modal-card">
  5. <header class="modal-card-head">
  6. <p class="modal-card-title">
  7. Login
  8. </p>
  9. <button class="delete" @click="closeCurrentModal()" />
  10. </header>
  11. <section class="modal-card-body">
  12. <!-- validation to check if exists http://bulma.io/documentation/elements/form/ -->
  13. <label class="label">Email</label>
  14. <p class="control">
  15. <input
  16. v-model="email"
  17. class="input"
  18. type="text"
  19. placeholder="Email..."
  20. />
  21. </p>
  22. <label class="label">Password</label>
  23. <p class="control">
  24. <input
  25. v-model="password"
  26. class="input"
  27. type="password"
  28. placeholder="Password..."
  29. @keypress="$parent.submitOnEnter(submitModal, $event)"
  30. />
  31. </p>
  32. <p>
  33. By logging in/registering you agree to our
  34. <router-link to="/terms"> Terms of Service </router-link
  35. >&nbsp;and
  36. <router-link to="/privacy"> Privacy Policy </router-link>.
  37. </p>
  38. </section>
  39. <footer class="modal-card-foot">
  40. <a
  41. class="button is-primary"
  42. href="#"
  43. @click="submitModal('login')"
  44. >Submit</a
  45. >
  46. <a
  47. class="button is-github"
  48. :href="$parent.serverDomain + '/auth/github/authorize'"
  49. @click="githubRedirect()"
  50. >
  51. <div class="icon">
  52. <img class="invert" src="/assets/social/github.svg" />
  53. </div>
  54. &nbsp;&nbsp;Login with GitHub
  55. </a>
  56. <a href="/reset_password" v-on:click="resetPassword()"
  57. >Forgot password?</a
  58. >
  59. </footer>
  60. </div>
  61. </div>
  62. </template>
  63. <script>
  64. import { mapActions } from "vuex";
  65. import { Toast } from "vue-roaster";
  66. export default {
  67. data: function() {
  68. return {
  69. email: "",
  70. password: ""
  71. };
  72. },
  73. methods: {
  74. submitModal: function() {
  75. this.login({
  76. email: this.email,
  77. password: this.password
  78. })
  79. .then(res => {
  80. if (res.status == "success") location.reload();
  81. })
  82. .catch(err => Toast.methods.addToast(err.message, 5000));
  83. },
  84. resetPassword: function() {
  85. this.closeModal({ sector: "header", modal: "login" });
  86. this.$router.go("/reset_password");
  87. },
  88. githubRedirect: function() {
  89. localStorage.setItem("github_redirect", this.$route.path);
  90. },
  91. ...mapActions("modals", ["closeModal", "closeCurrentModal"]),
  92. ...mapActions("user/auth", ["login"])
  93. }
  94. };
  95. </script>
  96. <style lang="scss" scoped>
  97. .button.is-github {
  98. background-color: #333;
  99. color: #fff !important;
  100. }
  101. .is-github:focus {
  102. background-color: #1a1a1a;
  103. }
  104. .is-primary:focus {
  105. background-color: #029ce3 !important;
  106. }
  107. .invert {
  108. filter: brightness(5);
  109. }
  110. a {
  111. color: #029ce3;
  112. }
  113. </style>