Add success message for password reset and handle token validation improvements

- Introduced a success message when password reset is completed, guiding users to log in.
- Refined token validation logic to handle expired or invalid tokens more accurately.
- Updated `PasswordResetConfirmationPage.vue` to display appropriate feedback based on reset status.
This commit is contained in:
Jeppe Bundgaard
2026-02-17 12:18:56 +01:00
parent ecf65b47a1
commit 6188c7734a
@@ -11,6 +11,7 @@ const router = useRouter();
const token = ref(router.currentRoute.value.params.token);
const isTokenValid = ref(null);
const newPassword = ref(null);
const hasSetPassword = ref(false);
const message = ref(null)
const timeoutId = ref(null)
@@ -22,9 +23,13 @@ const resetPasswordValidate = async () => {
params: {
token: token.value,
}
}).then(() => {
isTokenValid.value = true;
}).catch(() => {
isTokenValid.value = false;
parseError({response: {data: { data: { message: 'Invalid or expired token' }}}}, 'resetPasswordValidate');
});
isTokenValid.true = false;
} catch (error) {
parseError(error, 'resetPasswordValidate');
isTokenValid.value = false;
@@ -39,12 +44,13 @@ const createNewPassword = async () => {
password: newPassword.value
});
message.value = response.data.message;
message.value = response.data.data.message;
timeoutId.value = setTimeout(() => {
message.value = null;
}, 3000)
isTokenValid.true = false;
isTokenValid.value = false;
hasSetPassword.value = true;
} catch (error) {
parseError(error, 'resetPasswordConfirm');
isTokenValid.value = false;
@@ -75,6 +81,8 @@ onBeforeUnmount(() => {
<router-link :to="{ name: 'landing' }" class="logo">
<img :src="logo" alt="Truck Wash">
</router-link>
<!-- If the password has been successfully reset, show a success message and a link to the login page -->
<p v-if="hasSetPassword" class="help is-success">Password reset successful. Please log in.</p>
<form v-if="isTokenValid === false">
<p class="help is-danger" v-if="getError('resetPasswordValidate')">
{{ getError('resetPasswordValidate') }}