|
| 1 | +<template> |
| 2 | + <v-form @submit.prevent="handleAccept()" ref="form" v-model="valid"> |
| 3 | + <v-card> |
| 4 | + <v-card-text> |
| 5 | + <img :src="require('../assets/logo.png')" class="logo"> |
| 6 | + <template v-if="!loading"> |
| 7 | + <v-alert |
| 8 | + :value="errorMessage !== null" |
| 9 | + class="mb-4" |
| 10 | + transition="fade-transition" |
| 11 | + type="error" |
| 12 | + > |
| 13 | + {{errorMessage}} |
| 14 | + </v-alert> |
| 15 | + <v-text-field |
| 16 | + :rules="[(v) => !!v || 'E-Mail is verplicht']" |
| 17 | + label="E-Mail" |
| 18 | + v-model="email" |
| 19 | + ></v-text-field> |
| 20 | + <v-text-field |
| 21 | + :append-icon="showpassword ? 'fa-eye-slash' : 'fa-eye'" |
| 22 | + :rules="[(v) => !!v || 'Wachtwoord is verplicht', v => serverError('password', v)]" |
| 23 | + :type="showpassword ? 'text' : 'password'" |
| 24 | + @click:append="showpassword = !showpassword" |
| 25 | + label="Wachtwoord" |
| 26 | + v-model="password" |
| 27 | + ></v-text-field> |
| 28 | + <v-text-field |
| 29 | + :append-icon="showpassword ? 'fa-eye-slash' : 'fa-eye'" |
| 30 | + :rules="[(v) => !!v || 'Wachtwoord is verplicht']" |
| 31 | + :type="showpassword ? 'text' : 'password'" |
| 32 | + @click:append="showpassword = !showpassword" |
| 33 | + label="Wachtwoord" |
| 34 | + v-model="password_confirmation" |
| 35 | + ></v-text-field> |
| 36 | + </template> |
| 37 | + <div class="text-xs-center" v-else> |
| 38 | + <v-progress-circular |
| 39 | + :size="70" |
| 40 | + :width="7" |
| 41 | + color="accent" |
| 42 | + indeterminate |
| 43 | + ></v-progress-circular> |
| 44 | + </div> |
| 45 | + </v-card-text> |
| 46 | + <v-card-actions> |
| 47 | + <v-spacer></v-spacer> |
| 48 | + <v-btn @click="handleAccept()" type="submit" color="accent">Uitnodiging accepteren</v-btn> |
| 49 | + </v-card-actions> |
| 50 | + </v-card> |
| 51 | + </v-form> |
| 52 | +</template> |
| 53 | + |
| 54 | +<script> |
| 55 | +
|
| 56 | + export default { |
| 57 | + components: {}, |
| 58 | + watch: {}, |
| 59 | + props: [], |
| 60 | + name: '', |
| 61 | + data() { |
| 62 | + return { |
| 63 | + loading: false, |
| 64 | + valid: null, |
| 65 | + email: '', |
| 66 | + password: '', |
| 67 | + password_confirmation: '', |
| 68 | + errorMessage: null, |
| 69 | + showpassword: false, |
| 70 | + errors: {}, |
| 71 | + }; |
| 72 | + }, |
| 73 | + created() { |
| 74 | + if (this.$store.getters['Authorization/isLoggedIn']) { |
| 75 | + this.$router.push({name: 'home'}); |
| 76 | + } |
| 77 | + this.email = this.$route.query.email; |
| 78 | + }, |
| 79 | + methods: { |
| 80 | + handleAccept() { |
| 81 | + this.$refs.form.validate(); |
| 82 | + this.loading = true; |
| 83 | + this.$http.post('invitation/accept', { |
| 84 | + email: this.email, |
| 85 | + password: this.password, |
| 86 | + password_confirmation: this.password_confirmation, |
| 87 | + token: this.$route.params.token, |
| 88 | + }).then(() => { |
| 89 | + this.loading = false; |
| 90 | + this.handleLogin(); |
| 91 | + }).catch((error) => { |
| 92 | + this.loading = false; |
| 93 | + if (error.response.status === 422) { |
| 94 | + this.errors = error.response.data.errors; |
| 95 | + process.nextTick(() => { |
| 96 | + this.$refs.form.validate(); |
| 97 | + }); |
| 98 | + } else { |
| 99 | + this.errorMessage = 'Er ging iets mis.'; |
| 100 | + if(typeof error.response.data.message !== 'undefined' && error.response.data.message !== null) { |
| 101 | + this.errorMessage = error.response.data.message; |
| 102 | + } |
| 103 | + } |
| 104 | + }); |
| 105 | + }, |
| 106 | + handleLogin() { |
| 107 | + this.$router.push({name: 'login'}); |
| 108 | + }, serverError(name, v) { |
| 109 | + if (this.errors !== null && typeof this.errors[name] !== 'undefined') { |
| 110 | + return this.errors[name][0]; |
| 111 | + } |
| 112 | + return true; |
| 113 | + }, |
| 114 | + }, |
| 115 | + }; |
| 116 | +</script> |
| 117 | + |
| 118 | +<style scoped lang="scss"> |
| 119 | + .logo { |
| 120 | + display: block; |
| 121 | + margin: 0 auto; |
| 122 | + } |
| 123 | +</style> |
0 commit comments