[Reset password] Implemented reset password

This commit is contained in:
Matej Glasnák committed 2023-03-30 13:20:51 +02:00
1 parent 04774b0fb3
commit f8a1936f3e
7 files changed
+52 -19

No files matched your search

@@ -1,23 +1,19 @@
<template>
<v-form @keydown.enter="submit()">
<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 }" />
<v-text-field v-model="credentials.password" label="Heslo" autocomplete="new-password" bg-color="white" variant="solo" :type="showPassword ? 'text' : 'password'" class="mb-2" :hint="v$.credentials.password.$errors ? errorUtils.parseErrors(v$.credentials.password.$errors) : null" :class="{ error: v$.credentials.password.$errors.length }" :counter="12" :append-icon="showPassword ? 'mdi-eye' : 'mdi-eye-off'" @click:append="showPassword = !showPassword" />
<v-text-field v-model="credentials.password_confirmation" autocomplete="new-password" bg-color="white" variant="solo" label="Potvrdenie hesla" :type="showConfirmationPassword ? 'text' : 'password'" :counter="12" class="mb-2" :hint="v$.credentials.password_confirmation.$errors ? errorUtils.parseErrors(v$.credentials.password_confirmation.$errors) : null" :class="{ error: v$.credentials.password_confirmation.$errors.length }" :append-icon="showConfirmationPassword ? 'mdi-eye' : 'mdi-eye-off'" @click:append="showConfirmationPassword = !showConfirmationPassword" />
<div class="d-flex flex-column">
<v-btn class="button" color="#7F39FB" @click.prevent="submit()">Change password</v-btn>
<v-btn class="button" color="#7F39FB" @click.prevent="submit()" :disabled="!credentials.token">Change password</v-btn>
</div>
</v-form>
</template>
<script>
import useVuelidate from '@vuelidate/core'
import { required, email, integer, minLength, maxLength, sameAs } from '@vuelidate/validators'
import errorUtils from '@/plugins/lib@auth/_utils/error.utils'
import useVuelidate from '@vuelidate/core'
import { required, email, minLength, sameAs } from '@vuelidate/validators'
import errorUtils from '@/plugins/lib@auth/_utils/error.utils'
export default {
props: {
@@ -32,8 +28,8 @@ export default {
errorUtils,
v$: useVuelidate(),
credentials: {
token: this.$route.query.token,
email: this.$route.query.email
email: this.$route.query.email,
token: this.$route.query.token
},
showPassword: false,
showConfirmationPassword: false
@@ -43,7 +39,6 @@ export default {
validations() {
return {
credentials: {
token: { required },
email: { required, email },
password: { required, minLength: minLength(12) },
password_confirmation: { required, minLength: minLength(12), sameAs: sameAs(this.credentials.password)}
@@ -51,6 +46,11 @@ export default {
}
},
mounted() {
if (!this.$route.query.token)
return this.$toast.error('Error. Please check that the link is correct')
},
methods: {
async submit() {
if (!(await this.v$.$validate())) return