Register.vue 3.2 KB

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