feat: update authentication flow and user navigation

This commit is contained in:
2026-06-13 17:15:59 +02:00 Unverified
parent ab6455345e
commit a66339a7fc
18 changed files with 662 additions and 759 deletions
+4 -8
View File
@@ -9,7 +9,7 @@ const { changePassword, user, syncUser } = useAuth()
const router = useRouter()
const formData = reactive({
current_password: '', // FIX: rinominato da old_password
current_password: '',
new_password: '',
confirm_password: ''
})
@@ -17,7 +17,6 @@ const formData = reactive({
const isLoading = ref(false)
const errorMessage = ref('')
// FIX: Stati separati per la visibilità di ogni campo
const showCurrent = ref(false)
const showNew = ref(false)
const showConfirm = ref(false)
@@ -37,15 +36,14 @@ const handleSubmit = async () => {
errorMessage.value = ''
try {
// FIX: Payload con current_password come richiesto dall'API
const res = await changePassword({
current_password: formData.current_password,
new_password: formData.new_password
} as any) // Cast temporaneo se l'interfaccia types/api non è ancora aggiornata
})
if (res.ok) {
await syncUser()
await router.push('/me')
await router.push('/profile')
}
} catch (error: any) {
errorMessage.value = error.data?.message || 'Errore. Verifica la password attuale.'
@@ -73,8 +71,6 @@ const handleSubmit = async () => {
<h3 class="card-title h4 mb-4">Cambia la tua password</h3>
<form @submit.prevent="handleSubmit">
<!-- 1. PASSWORD ATTUALE -->
<div class="form-group mb-3">
<div class="input-group">
<div class="input-group-prepend">
@@ -185,4 +181,4 @@ const handleSubmit = async () => {
.form-control:focus + label {
color: #006f9d;
}
</style>
</style>