From b75e7bbafd714cb2efea7b98224c182f980cb079 Mon Sep 17 00:00:00 2001 From: gabdevele Date: Tue, 16 Jun 2026 11:53:22 +0200 Subject: [PATCH] refractor(auth): removed password from everywhere --- app/composables/useAuth.ts | 15 +- app/pages/auth/change-password.vue | 217 ----------------------------- app/pages/auth/login.vue | 104 +++----------- app/pages/auth/register.vue | 36 +---- app/pages/info.vue | 2 +- app/pages/privacy.vue | 4 +- app/pages/profile.vue | 3 +- app/types/api.d.ts | 13 -- public/sprites.svg | 2 +- 9 files changed, 37 insertions(+), 359 deletions(-) delete mode 100644 app/pages/auth/change-password.vue diff --git a/app/composables/useAuth.ts b/app/composables/useAuth.ts index 274f72c..30ec5b1 100644 --- a/app/composables/useAuth.ts +++ b/app/composables/useAuth.ts @@ -1,8 +1,7 @@ import type { - ChangePasswordRequest, CurrentUserResponse, EmailRequest, NotificationListResponse, OkResponse, - OtpRequestResponse, PasswordLoginRequest, RegisterCitizenRequest, + OtpRequestResponse, RegisterCitizenRequest, RegisterCitizenResponse, RewardsResponse, TokenResponse, VerifyOtpRequest, UpdateProfileRequest } from "~/types/api"; @@ -44,9 +43,7 @@ export const useAuth = () => { user.value = res.user const path = currentPath ?? useNuxtApp().$router.currentRoute.value.path - if (res.user.must_change_password && path !== '/auth/change-password') { - await nuxtApp.runWithContext(() => navigateTo('/auth/change-password')) - } else if (redirectOnSuccess && path.startsWith('/auth')) { + if (redirectOnSuccess && path.startsWith('/auth')) { await nuxtApp.runWithContext(() => navigateTo('/dashboard')) } } @@ -85,12 +82,6 @@ export const useAuth = () => { const verifyOtp = (body: VerifyOtpRequest) => useApiFetch('/api/v1/auth/otp/verify', { method: 'POST', body }) - const loginWithPassword = (body: PasswordLoginRequest) => - useApiFetch('/api/v1/auth/login/password', { method: 'POST', body }) - - const changePassword = (body: ChangePasswordRequest) => - useApiFetch('/api/v1/auth/change-password', { method: 'POST', body }) - const updateProfile = (body: UpdateProfileRequest) => useApiFetch('/api/v1/me', { method: 'PATCH', body }) @@ -119,8 +110,6 @@ export const useAuth = () => { register, requestOtp, verifyOtp, - loginWithPassword, - changePassword, updateProfile, fetchCurrentUser, fetchRewards, diff --git a/app/pages/auth/change-password.vue b/app/pages/auth/change-password.vue deleted file mode 100644 index 57d1145..0000000 --- a/app/pages/auth/change-password.vue +++ /dev/null @@ -1,217 +0,0 @@ - - - - - diff --git a/app/pages/auth/login.vue b/app/pages/auth/login.vue index b92f771..38ccab9 100644 --- a/app/pages/auth/login.vue +++ b/app/pages/auth/login.vue @@ -7,20 +7,15 @@ definePageMeta({ useHead({ title: 'Accedi - Visione' }) -const { requestOtp, verifyOtp, loginWithPassword, handleLoginSuccess } = useAuth() -const router = useRouter() +const { requestOtp, verifyOtp, handleLoginSuccess } = useAuth() // UI State -const loginMethod = ref<'otp' | 'password'>('otp') const otpStep = ref<1 | 2>(1) const isLoading = ref(false) const errorMessage = ref('') - const email = ref('') -const password = ref('') const otpCode = ref('') -const showPassword = ref(false) const handleRequestOtp = async () => { isLoading.value = true @@ -47,19 +42,6 @@ const handleVerifyOtp = async () => { isLoading.value = false } } - -const handlePasswordLogin = async () => { - isLoading.value = true - errorMessage.value = '' - try { - const res = await loginWithPassword({ email: email.value, password: password.value }) - await handleLoginSuccess(res.token) - } catch (err: any) { - errorMessage.value = 'Credenziali non valide.' - } finally { - isLoading.value = false - } -} diff --git a/app/pages/info.vue b/app/pages/info.vue index 129ba50..e5f9c76 100644 --- a/app/pages/info.vue +++ b/app/pages/info.vue @@ -112,7 +112,7 @@ useHead({
  • - Sicurezza: Login Passwordless (OTP nativo) e sistema di autorizzazione Role-Based basato su token JWT. + Sicurezza: Accesso con OTP e sistema di autorizzazione Role-Based basato su token JWT.
  • diff --git a/app/pages/privacy.vue b/app/pages/privacy.vue index f70aed5..25964ea 100644 --- a/app/pages/privacy.vue +++ b/app/pages/privacy.vue @@ -48,7 +48,7 @@ useHead({

    3. Finalità del Trattamento

    I dati forniti verranno trattati esclusivamente per le seguenti finalità: -
    - Consentire la registrazione e l'autenticazione sicura (incluso login Passwordless tramite OTP). +
    - Consentire la registrazione e l'autenticazione sicura tramite OTP.
    - Gestire la presa in carico e la risoluzione delle segnalazioni urbane da parte delle squadre operative.
    - Fornire comunicazioni di servizio relative allo stato di avanzamento delle segnalazioni.
    - Attribuire punteggi virtuali all'utente nell'ambito del sistema di Gamification volto a incentivare la cittadinanza attiva. @@ -82,4 +82,4 @@ useHead({ - \ No newline at end of file + diff --git a/app/pages/profile.vue b/app/pages/profile.vue index d9a7871..f65d6c8 100644 --- a/app/pages/profile.vue +++ b/app/pages/profile.vue @@ -132,7 +132,6 @@ const formatDate = (dateString: string) =>

    Nuova segnalazione Notifiche - Cambia password @@ -159,4 +158,4 @@ const formatDate = (dateString: string) => .card .card-body .d-grid > a { padding-block: 8px; } - \ No newline at end of file + diff --git a/app/types/api.d.ts b/app/types/api.d.ts index 4c5b15d..81ea2eb 100644 --- a/app/types/api.d.ts +++ b/app/types/api.d.ts @@ -29,7 +29,6 @@ export interface CurrentUser { email: string; fiscal_code: string; points: number; - must_change_password: boolean; role: string; roles: string[]; permissions: string[]; @@ -45,7 +44,6 @@ export interface AdminUser { phone?: string; banned?: boolean; points?: number; - must_change_password?: boolean; roles?: string; // Comma-separated } @@ -191,23 +189,12 @@ export interface RegisterCitizenRequest { first_name: string; last_name: string; email: string; - password: string; fiscal_code: string; phone?: string; birth_date?: string; birth_place?: string; } -export interface PasswordLoginRequest { - email: string; - password: string; -} - -export interface ChangePasswordRequest { - current_password: string; - new_password: string; -} - export interface UpdateProfileRequest { first_name?: string; last_name?: string; diff --git a/public/sprites.svg b/public/sprites.svg index b3c20b2..f0cd53b 100644 --- a/public/sprites.svg +++ b/public/sprites.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file