Register.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <template>
  2. <div class="modal is-active">
  3. <div class="modal-background" />
  4. <div class="modal-card">
  5. <header class="modal-card-head">
  6. <p class="modal-card-title">
  7. Register
  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. autofocus
  21. />
  22. </p>
  23. <label class="label">Username</label>
  24. <p class="control">
  25. <input
  26. v-model="username"
  27. class="input"
  28. type="text"
  29. placeholder="Username..."
  30. />
  31. </p>
  32. <label class="label">Password</label>
  33. <p class="control">
  34. <input
  35. v-model="password"
  36. class="input"
  37. type="password"
  38. placeholder="Password..."
  39. @keypress="$parent.submitOnEnter(submitModal, $event)"
  40. />
  41. </p>
  42. <div id="recaptcha" />
  43. <p>
  44. By logging in/registering you agree to our
  45. <router-link to="/terms"> Terms of Service </router-link
  46. >&nbsp;and
  47. <router-link to="/privacy"> Privacy Policy </router-link>.
  48. </p>
  49. </section>
  50. <footer class="modal-card-foot">
  51. <a class="button is-primary" href="#" @click="submitModal()"
  52. >Submit</a
  53. >
  54. <a
  55. class="button is-github"
  56. :href="$parent.serverDomain + '/auth/github/authorize'"
  57. @click="githubRedirect()"
  58. >
  59. <div class="icon">
  60. <img class="invert" src="/assets/social/github.svg" />
  61. </div>
  62. &nbsp;&nbsp;Register with GitHub
  63. </a>
  64. </footer>
  65. </div>
  66. </div>
  67. </template>
  68. <script>
  69. import { mapActions } from "vuex";
  70. import { Toast } from "vue-roaster";
  71. export default {
  72. data() {
  73. return {
  74. username: "",
  75. email: "",
  76. password: "",
  77. recaptcha: {
  78. key: ""
  79. }
  80. };
  81. },
  82. mounted: function() {
  83. let _this = this;
  84. lofig.get("recaptcha", obj => {
  85. _this.recaptcha.key = obj.key;
  86. _this.recaptcha.id = grecaptcha.render("recaptcha", {
  87. sitekey: _this.recaptcha.key
  88. });
  89. });
  90. },
  91. methods: {
  92. submitModal: function() {
  93. this.register(
  94. {
  95. username: this.username,
  96. email: this.email,
  97. password: this.password
  98. },
  99. this.recaptcha.id
  100. )
  101. .then(res => {
  102. if (res.status == "success") location.reload();
  103. })
  104. .catch(err => Toast.methods.addToast(err.message, 5000));
  105. },
  106. githubRedirect: function() {
  107. localStorage.setItem("github_redirect", this.$route.path);
  108. },
  109. ...mapActions("modals", ["toggleModal", "closeCurrentModal"]),
  110. ...mapActions("user/auth", ["register"])
  111. }
  112. };
  113. </script>
  114. <style lang="scss" scoped>
  115. .button.is-github {
  116. background-color: #333;
  117. color: #fff !important;
  118. }
  119. .is-github:focus {
  120. background-color: #1a1a1a;
  121. }
  122. .is-primary:focus {
  123. background-color: #028bca !important;
  124. }
  125. .invert {
  126. filter: brightness(5);
  127. }
  128. #recaptcha {
  129. padding: 10px 0;
  130. }
  131. a {
  132. color: #029ce3;
  133. }
  134. </style>