[Forgot, reset] Connected to BE

This commit is contained in:
Matej Glasnák committed 2023-03-29 22:46:28 +02:00
1 parent 850b400a8c
commit 04774b0fb3
6 files changed
+10 -24

No files matched your search

@@ -45,7 +45,8 @@ export default {
try {
await this.$store.dispatch('auth/forgotPassword', this.credentials)
this.$router.push(`${this.navigateToAfterForgotPassword}?email=${this.credentials.email}`)
this.$router.push({name: 'Reset password', query: {email: this.credentials.email}})
this.$toast.success('Reset code has been sent to your email.')
} catch (error) {
this.$toast.error(error)
}
@@ -1,6 +1,6 @@
<template>
<v-form @keydown.enter="submit()">
<v-text-field v-model="credentials.code" label="Code" autocomplete="one-time-code" bg-color="white" variant="solo" type="number" class="mb-2" :hint="v$.credentials.code.$errors ? errorUtils.parseErrors(v$.credentials.code.$errors) : null" :counter="6" :class="{ error: v$.credentials.code.$errors.length }" />
<v-text-field v-model="credentials.token" label="Token" autocomplete="one-time-token" bg-color="white" variant="solo" type="number" class="mb-2" :hint="v$.credentials.token.$errors ? errorUtils.parseErrors(v$.credentials.token.$errors) : null" :counter="6" :class="{ error: v$.credentials.token.$errors.length }" />
<v-text-field v-model="credentials.email" label="E-mail" autocomplete="email" bg-color="white" variant="solo" type="email" class="mb-2" :hint="v$.credentials.email.$errors ? errorUtils.parseErrors(v$.credentials.email.$errors) : null" :class="{ error: v$.credentials.email.$errors.length }" />
@@ -32,10 +32,8 @@ export default {
errorUtils,
v$: useVuelidate(),
credentials: {
code: '',
email: '',
password: '',
password_confirmation: ''
token: this.$route.query.token,
email: this.$route.query.email
},
showPassword: false,
showConfirmationPassword: false
@@ -45,19 +43,14 @@ export default {
validations() {
return {
credentials: {
code: { required, integer, minLength: minLength(6), maxLength: maxLength(6) },
token: { required },
email: { required, email },
password: { required, minLength: minLength(12) },
password_confirmation: { required, minLength: minLength(12), sameAs: sameAs(this.form.password)}
password_confirmation: { required, minLength: minLength(12), sameAs: sameAs(this.credentials.password)}
}
}
},
created() {
this.credentials.email = new URLSearchParams(window.location.search.substring(1).get('email'))
this.credentials.code = new URLSearchParams(window.location.search.substring(1).get('code'))
},
methods: {
async submit() {
if (!(await this.v$.$validate())) return
@@ -65,6 +58,7 @@ export default {
try {
await this.$store.dispatch('auth/resetPassword', this.credentials)
this.$router.push({ name: 'Login' })
this.$toast.success('Your password has been successfully changed.')
} catch (error) {
this.$toast.error(error)
}