Login.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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. <form>
  30. <label class="label">Email</label>
  31. <p class="control">
  32. <input
  33. v-model="email"
  34. class="input"
  35. type="email"
  36. placeholder="Email..."
  37. />
  38. </p>
  39. <label class="label">Password</label>
  40. <p class="control">
  41. <input
  42. v-model="password"
  43. class="input"
  44. type="password"
  45. placeholder="Password..."
  46. @keypress="
  47. $parent.submitOnEnter(submitModal, $event)
  48. "
  49. />
  50. </p>
  51. <p>
  52. By logging in/registering you agree to our
  53. <router-link to="/terms"> Terms of Service </router-link
  54. >&nbsp;and
  55. <router-link to="/privacy"> Privacy Policy </router-link
  56. >.
  57. </p>
  58. </form>
  59. </section>
  60. <footer class="modal-card-foot">
  61. <a class="button is-primary" href="#" @click="submitModal()"
  62. >Submit</a
  63. >
  64. <a
  65. class="button is-github"
  66. :href="serverDomain + '/auth/github/authorize'"
  67. @click="githubRedirect()"
  68. >
  69. <div class="icon">
  70. <img class="invert" src="/assets/social/github.svg" />
  71. </div>
  72. &nbsp;&nbsp;Login with GitHub
  73. </a>
  74. <a href="/reset_password" v-on:click="resetPassword()"
  75. >Forgot password?</a
  76. >
  77. </footer>
  78. </div>
  79. </div>
  80. </template>
  81. <script>
  82. import { mapActions } from "vuex";
  83. import Toast from "toasters";
  84. export default {
  85. data() {
  86. return {
  87. email: "",
  88. password: "",
  89. serverDomain: ""
  90. };
  91. },
  92. methods: {
  93. submitModal() {
  94. this.login({
  95. email: this.email,
  96. password: this.password
  97. })
  98. .then(res => {
  99. if (res.status === "success") window.location.reload();
  100. })
  101. .catch(
  102. err => new Toast({ content: err.message, timeout: 5000 })
  103. );
  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. },
  112. ...mapActions("modals", ["closeModal"]),
  113. ...mapActions("user/auth", ["login"])
  114. },
  115. mounted() {
  116. lofig.get("serverDomain").then(serverDomain => {
  117. this.serverDomain = serverDomain;
  118. });
  119. }
  120. };
  121. </script>
  122. <style lang="scss" scoped>
  123. @import "styles/global.scss";
  124. .button.is-github {
  125. background-color: $dark-grey-2;
  126. color: $white !important;
  127. }
  128. .is-github:focus {
  129. background-color: $dark-grey-3;
  130. }
  131. .is-primary:focus {
  132. background-color: $primary-color !important;
  133. }
  134. .invert {
  135. filter: brightness(5);
  136. }
  137. a {
  138. color: $primary-color;
  139. }
  140. </style>