fix: auth flow - logout nuclear, router redirige admin a panel, login sin bloqueo BD
This commit is contained in:
@ -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)
|
||||
|
||||
Reference in New Issue
Block a user