From 1d8ad90151d8566e13825bd60cd9d63a4e7a9298 Mon Sep 17 00:00:00 2001 From: ReLoia Date: Fri, 12 Jun 2026 22:41:25 +0200 Subject: [PATCH] feat: support change-password and admin must_change_password --- app/composables/useAuth.ts | 8 ++ app/pages/auth/change-password.vue | 188 +++++++++++++++++++++++++++++ app/pages/auth/login.vue | 1 - 3 files changed, 196 insertions(+), 1 deletion(-) create mode 100644 app/pages/auth/change-password.vue diff --git a/app/composables/useAuth.ts b/app/composables/useAuth.ts index 872040f..892ed2f 100644 --- a/app/composables/useAuth.ts +++ b/app/composables/useAuth.ts @@ -35,6 +35,14 @@ export const useAuth = () => { if (res.ok) { console.log('[Auth] User synced successfully') user.value = res.user + + const route = useRoute() + if (res.user.must_change_password && route.path !== '/auth/change-password') { + console.log('[Auth] User must change password, redirecting...') + await navigateTo('/auth/change-password') + } else { + await navigateTo('/dashboard') + } } } catch (error) { console.error('[Auth] Sync failed, logging out:', error) diff --git a/app/pages/auth/change-password.vue b/app/pages/auth/change-password.vue new file mode 100644 index 0000000..9271687 --- /dev/null +++ b/app/pages/auth/change-password.vue @@ -0,0 +1,188 @@ + + + + + \ No newline at end of file diff --git a/app/pages/auth/login.vue b/app/pages/auth/login.vue index 5e4f83d..580a0da 100644 --- a/app/pages/auth/login.vue +++ b/app/pages/auth/login.vue @@ -55,7 +55,6 @@ const handlePasswordLogin = async () => { try { const res = await loginWithPassword({ email: email.value, password: password.value }) await handleLoginSuccess(res.token) - router.push('/dashboard') } catch (err: any) { errorMessage.value = 'Credenziali non valide.' } finally {