Login.vue 3.2 KB

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