Advertisement
Guest User

Untitled

a guest
Apr 6th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.97 KB | None | 0 0
  1. <template>
  2. <div class="auth">
  3. <h2>{{ formState === 'signUp' ? 'Sign Up' : 'Confirm Sign Up' }}</h2>
  4. <form @submit.prevent="signUp">
  5. <div v-if="formState === 'signUp'">
  6. <q-input square filled color="teal" label="Username" v-model="form.username"/>
  7. <q-input
  8. square
  9. filled
  10. color="teal"
  11. label="Password"
  12. type="password"
  13. v-model="form.password"
  14. />
  15. <q-input square filled color="teal" label="E-mail" v-model="form.email"/>
  16. <div class="row">
  17. <q-btn type="submit" @click="signUp" label="Sign Up" class="authButton">
  18. <template v-slot:loading>
  19. <q-spinner-facebook/>
  20. </template>
  21. </q-btn>
  22. </div>
  23. </div>
  24. <div v-if="formState === 'confirmSignUp'">
  25. <q-input square filled color="teal" v-model="form.authCode"/>
  26. <div class="row">
  27. <q-btn type="submit" @click="confirmSignUp" label="Verification code" class="authButton">
  28. <template v-slot:loading>
  29. <q-spinner-facebook/>
  30. </template>
  31. </q-btn>
  32. </div>
  33. </div>
  34. </form>
  35. </div>
  36. </template>
  37. <script>
  38. export default {
  39. name: 'home',
  40. props: ['toggle'],
  41. data () {
  42. return {
  43. formState: 'signUp',
  44. form: {
  45. username: '',
  46. password: '',
  47. email: ''
  48. }
  49. }
  50. },
  51. methods: {
  52. async signUp () {
  53. const { username, password, email } = this.form
  54. await this.$Auth.signUp({
  55. username, password, attributes: { email }
  56. })
  57. this.formState = 'confirmSignUp'
  58. },
  59. async confirmSignUp () {
  60. const { username, authCode } = this.form
  61. await this.$Auth.confirmSignUp(username, authCode)
  62. this.toggle()
  63. }
  64. }
  65. }
  66. </script>
  67. <style>
  68. .authButton {
  69. width: 100%;
  70. padding: 10px;
  71. margin-top: 10px;
  72. background-color: #2196f3;
  73. border: none;
  74. color: white;
  75. outline: none;
  76. }
  77. .auth {
  78. margin: 0 auto;
  79. width: 460px;
  80. }
  81. </style>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement