Login.vue 2.9 KB

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