fix: auth flow - logout nuclear, router redirige admin a panel, login sin bloqueo BD

This commit is contained in:
2026-02-25 22:38:03 -05:00
parent 84055a25de
commit 963d255ea2
4 changed files with 69 additions and 28 deletions

View File

@ -17,16 +17,18 @@ const authStore = useAuthStore()
const handleLogin = async () => {
isLoading.value = true
errorMessage.value = ''
console.log('Iniciando Login con correo...')
try {
await authStore.login(email.value.trim().toLowerCase(), password.value)
// Esperar a que el perfil se cargue globalmente para saber a qué pantalla navegar
setTimeout(() => {
const r = authStore.role || 'PASSENGER'
navigateByUserRole(r)
}, 800)
// Esperar hasta que el perfil esté cargado (máx 3 segundos)
let attempts = 0
while (!authStore.role && attempts < 30) {
await new Promise(res => setTimeout(res, 100))
attempts++
}
navigateByUserRole(authStore.role || 'PASSENGER')
} catch (error: any) {
console.error('Error Login detallado:', error)