2023-10-30 15:13:50 +01:00
|
|
|
<script setup>
|
|
|
|
import Form from '@/components/formElements/Form'
|
|
|
|
import { useNotifyStore } from '@/stores/notify'
|
|
|
|
|
|
|
|
const notify = useNotifyStore()
|
2023-10-31 08:21:38 +01:00
|
|
|
const route = useRoute()
|
|
|
|
|
|
|
|
const isWebauthnReset = route.name == 'webauthn.lost'
|
2023-10-30 15:13:50 +01:00
|
|
|
|
|
|
|
const form = reactive(new Form({
|
|
|
|
email: '',
|
|
|
|
}))
|
|
|
|
|
|
|
|
/**
|
2023-10-31 08:21:38 +01:00
|
|
|
* Submits the reset request to the backend
|
2023-10-30 15:13:50 +01:00
|
|
|
*/
|
|
|
|
function requestPasswordReset(e) {
|
2023-10-31 08:21:38 +01:00
|
|
|
notify.clear()
|
|
|
|
form.post(isWebauthnReset ? '/webauthn/lost' : '/user/password/lost', {returnError: true})
|
2023-10-30 15:13:50 +01:00
|
|
|
.then(response => {
|
|
|
|
notify.success({ text: response.data.message, duration:-1 })
|
|
|
|
})
|
|
|
|
.catch(error => {
|
|
|
|
console.log(error)
|
|
|
|
if( error.response.data.requestFailed ) {
|
|
|
|
notify.alert({ text: error.response.data.requestFailed, duration:-1 })
|
|
|
|
}
|
|
|
|
else if( error.response.status !== 422 ) {
|
|
|
|
notify.error(error)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
onBeforeRouteLeave(() => {
|
|
|
|
notify.clear()
|
|
|
|
})
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2023-10-31 08:21:38 +01:00
|
|
|
<FormWrapper :title="$t(isWebauthnReset ? 'auth.webauthn.account_recovery' : 'auth.forms.reset_password')" :punchline="$t(isWebauthnReset ? 'auth.webauthn.recovery_punchline' : 'auth.forms.reset_punchline')">
|
2023-10-30 15:13:50 +01:00
|
|
|
<form @submit.prevent="requestPasswordReset" @keydown="form.onKeydown($event)">
|
|
|
|
<FormField v-model="form.email" fieldName="email" :fieldError="form.errors.get('email')" label="auth.forms.email" autofocus />
|
|
|
|
<FormButtons
|
|
|
|
:submitId="'btnSendResetPwd'"
|
|
|
|
:isBusy="form.isBusy"
|
2023-10-31 08:21:38 +01:00
|
|
|
:caption="$t(isWebauthnReset ? 'auth.webauthn.send_recovery_link' : 'auth.forms.send_password_reset_link')"
|
2023-10-30 15:13:50 +01:00
|
|
|
:showCancelButton="true"
|
|
|
|
cancelLandingView="login" />
|
|
|
|
</form>
|
|
|
|
<VueFooter />
|
|
|
|
</FormWrapper>
|
|
|
|
</template>
|