[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

@@ -110,8 +110,6 @@ export default class DateUtils {
}
getWeek (date) {
console.log(date)
console.log('kokot')
const d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()))
const dayNum = d.getUTCDay() || 7
d.setUTCDate(d.getUTCDate() + 4 - dayNum)
@@ -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)
}
@@ -78,10 +78,6 @@ export default {
}
})
console.log(blockers)
return blockers
},
@@ -121,8 +117,6 @@ export default {
})
}
console.log(events)
return events
},
@@ -125,7 +125,6 @@ export default {
this.config.date = this.filter.start
this.subtasks = [...subtasks, ...blockers.map(blocker => ({...blocker, type: 'blocker'}))]
} catch (error) {
console.log(error)
this.$toast.error('Nepodarilo sa nacitat data!')
}
}
+2 -2
View File
@@ -86,7 +86,7 @@ export default {
// eslint-disable-next-line
forgotPassword({commit}: {commit: any}, credentials: any) {
return new Promise((resolve, reject) => {
axios.post_auth_data('v1/users/forgot', credentials)
axios.post('v1/users/forgot', {data: credentials})
.then(response => resolve(response))
.catch(error => reject(error))
})
@@ -94,7 +94,7 @@ export default {
// eslint-disable-next-line
resetPassword({commit}: {commit: any}, credentials: any) {
return new Promise((resolve, reject) => {
axios.post_auth_data('v1/users/reset', credentials)
axios.post_auth_data('v1/users/reset', {data: credentials})
.then(response => resolve(response))
.catch(error => reject(error))
})