index.vue 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <template>
  2. <div class="md-layout md-alignment-center-center" style="height: 100vh;">
  3. <md-card class="md-layout-item md-size-50">
  4. <md-card-header>
  5. <div class="md-title">
  6. Register
  7. </div>
  8. </md-card-header>
  9. <form @submit.prevent="resisterUser">
  10. <md-card-content>
  11. <md-field md-clearable>
  12. <label for="email">Email</label>
  13. <md-input
  14. id="email"
  15. v-model="form.email"
  16. :disabled="loading"
  17. type="email"
  18. name="email"
  19. autocomplete="email"
  20. />
  21. </md-field>
  22. <md-field>
  23. <label for="password">password</label>
  24. <md-input
  25. id="password"
  26. v-model="form.password"
  27. :disabled="loading"
  28. type="password"
  29. name="password"
  30. autocomplete="password"
  31. />
  32. </md-field>
  33. </md-card-content>
  34. <md-card-actions>
  35. <md-button to="/login">
  36. Go To Login
  37. </md-button>
  38. <md-button class="md-primary md-raised" type="submit">
  39. Submit
  40. </md-button>
  41. </md-card-actions>
  42. </form>
  43. <md-snackbar :md-active.sync="isAuthenticated">
  44. {{ form.email }} was successfully registerd!
  45. </md-snackbar>
  46. </md-card>
  47. </div>
  48. </template>
  49. <script>
  50. export default {
  51. data: () => ({
  52. form: {
  53. email: '',
  54. password: ''
  55. }
  56. }),
  57. computed: {
  58. loading () {
  59. return this.$store.getters.loading
  60. },
  61. isAuthenticated () {
  62. return this.$store.getters.isAuthenticated
  63. }
  64. },
  65. watch: {
  66. isAuthenticated (value) {
  67. if (value) {
  68. setTimeout(() => this.$router.push('/'), 2000)
  69. }
  70. }
  71. },
  72. methods: {
  73. async resisterUser () {
  74. await this.$store.dispatch('authenticateUser', {
  75. email: this.form.email,
  76. password: this.form.password,
  77. resturnSecureToken: true
  78. })
  79. }
  80. }
  81. }
  82. </script>