From 69061a081f549c4d70d991d8ed0f25c797c82184 Mon Sep 17 00:00:00 2001 From: Hanzo_dev <2002samudiojohan@gmail.com> Date: Sun, 22 Feb 2026 18:04:52 -0500 Subject: [PATCH] fix: redesign auth UI to match SIBU design system, fix login bug - AuthView: removed Tailwind/HUD aesthetic, uses SIBU CSS variables and Space Grotesk font, tab-based login/register switch - LoginForm: fix critical bug - email now sent lowercase to backend (was causing 401 errors), added show/hide password toggle, human labels replacing sci-fi terminology - RegisterForm: same fixes - lowercase email, human UX, SIBU theme variables - Both forms: removed all hardcoded Tailwind colors, now consistent with dark/light theme system --- frontend/src/components/auth/LoginForm.vue | 410 +++++++++++++++--- frontend/src/components/auth/RegisterForm.vue | 349 ++++++++++++--- frontend/src/views/AuthView.vue | 254 ++++++----- 3 files changed, 766 insertions(+), 247 deletions(-) diff --git a/frontend/src/components/auth/LoginForm.vue b/frontend/src/components/auth/LoginForm.vue index d0bb6ec..9d25151 100644 --- a/frontend/src/components/auth/LoginForm.vue +++ b/frontend/src/components/auth/LoginForm.vue @@ -12,34 +12,35 @@ const password = ref('') const keepSession = ref(false) const isLoading = ref(false) const errorMessage = ref('') +const showPassword = ref(false) const router = useRouter() const authStore = useAuthStore() const handleLogin = async () => { isLoading.value = true errorMessage.value = '' - + try { const response = await authService.login({ - email: email.value, + // CRÍTICO: enviar email en minúsculas para evitar mismatch con el backend + email: email.value.trim().toLowerCase(), password: password.value, keep_session: keepSession.value }) - + authStore.login(response.access_token, response.role, response.full_name) - - // Redirect based on role or home + const role = response.role.toUpperCase() if (role === 'ADMIN') router.push('/admin') else if (role === 'DRIVER') router.push('/driver') else if (role === 'PROMOTER') router.push('/promoter') else router.push('/map') - + } catch (error: any) { if (!error.response) { errorMessage.value = 'Error de conexión. Verifica tu internet.' } else if (error.response.status === 401) { - errorMessage.value = 'Credenciales inválidas.' + errorMessage.value = 'Correo o contraseña incorrectos.' } else { errorMessage.value = error.response?.data?.detail || 'Error en el servidor.' } @@ -51,19 +52,19 @@ const handleLogin = async () => { const handleGoogleLogin = async () => { isLoading.value = true errorMessage.value = '' - + try { const { token } = await signInWithGoogle() const response = await authService.googleLogin(token) - + authStore.login(response.access_token, response.role, response.full_name) - + const role = response.role.toUpperCase() if (role === 'ADMIN') router.push('/admin') else if (role === 'DRIVER') router.push('/driver') else if (role === 'PROMOTER') router.push('/promoter') else router.push('/map') - + } catch (error: any) { errorMessage.value = 'Error al iniciar sesión con Google.' console.error(error) @@ -74,84 +75,349 @@ const handleGoogleLogin = async () => { diff --git a/frontend/src/components/auth/RegisterForm.vue b/frontend/src/components/auth/RegisterForm.vue index 79c5506..8e43864 100644 --- a/frontend/src/components/auth/RegisterForm.vue +++ b/frontend/src/components/auth/RegisterForm.vue @@ -11,27 +11,26 @@ const password = ref('') const isLoading = ref(false) const errorMessage = ref('') const successMessage = ref('') +const showPassword = ref(false) const handleRegister = async () => { isLoading.value = true errorMessage.value = '' - + try { await authService.registerPassenger({ - full_name: fullName.value, - email: email.value, + full_name: fullName.value.trim(), + email: email.value.trim().toLowerCase(), password: password.value }) - - analyticsService.logEvent({ - event_name: 'sign_up', - properties: { method: 'email' } + + analyticsService.logEvent({ + event_name: 'sign_up', + properties: { method: 'email' } }) - - successMessage.value = 'Registro exitoso. Ahora puedes entrar.' - setTimeout(() => { - emit('success') - }, 2000) + + successMessage.value = '¡Cuenta creada! Ahora puedes iniciar sesión.' + setTimeout(() => { emit('success') }, 2000) } catch (error: any) { errorMessage.value = error.response?.data?.detail || 'Error al crear la cuenta.' } finally { @@ -41,73 +40,293 @@ const handleRegister = async () => { + + diff --git a/frontend/src/views/AuthView.vue b/frontend/src/views/AuthView.vue index fb1c702..a97ce8c 100644 --- a/frontend/src/views/AuthView.vue +++ b/frontend/src/views/AuthView.vue @@ -4,141 +4,175 @@ import LoginForm from '@/components/auth/LoginForm.vue' import RegisterForm from '@/components/auth/RegisterForm.vue' const isLogin = ref(true) - -const toggleAuth = () => { - isLogin.value = !isLogin.value -} +const toggleAuth = () => { isLogin.value = !isLogin.value }