Login.vue 3.1 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. <label class="label">Email</label>
  29. <p class="control">
  30. <input
  31. v-model="email"
  32. class="input"
  33. type="email"
  34. placeholder="Email..."
  35. />
  36. </p>
  37. <label class="label">Password</label>
  38. <p class="control">
  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. <p>
  50. By logging in/registering you agree to our
  51. <router-link to="/terms"> Terms of Service </router-link
  52. >&nbsp;and
  53. <router-link to="/privacy"> Privacy Policy </router-link
  54. >.
  55. </p>
  56. </form>
  57. </section>
  58. <footer class="modal-card-foot">
  59. <a class="button is-primary" href="#" @click="submitModal()"
  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 "toasters";
  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.href = "/";
  98. })
  99. .catch(
  100. err => new Toast({ content: err.message, timeout: 5000 })
  101. );
  102. },
  103. resetPassword() {
  104. this.closeModal({ sector: "header", modal: "login" });
  105. this.$router.go("/reset_password");
  106. },
  107. githubRedirect() {
  108. localStorage.setItem("github_redirect", this.$route.path);
  109. },
  110. ...mapActions("modals", ["closeModal"]),
  111. ...mapActions("user/auth", ["login"])
  112. },
  113. mounted() {
  114. lofig.get("serverDomain").then(serverDomain => {
  115. this.serverDomain = serverDomain;
  116. });
  117. }
  118. };
  119. </script>
  120. <style lang="scss" scoped>
  121. @import "../../styles/global.scss";
  122. .night-mode {
  123. .modal-card,
  124. .modal-card-head,
  125. .modal-card-body,
  126. .modal-card-foot {
  127. background-color: $night-mode-secondary;
  128. }
  129. .label,
  130. p {
  131. color: #ddd;
  132. }
  133. }
  134. .button.is-github {
  135. background-color: $dark-grey-2;
  136. color: $white !important;
  137. }
  138. .is-github:focus {
  139. background-color: $dark-grey-3;
  140. }
  141. .is-primary:focus {
  142. background-color: $primary-color !important;
  143. }
  144. .invert {
  145. filter: brightness(5);
  146. }
  147. a {
  148. color: $primary-color;
  149. }
  150. </style>