Update login.go

This commit is contained in:
Lizandro Guarnizo
2026-05-15 16:05:27 -05:00
parent f7e8d273d2
commit 750e3172ff
+11
View File
@@ -13,6 +13,10 @@ func RedirectToHomePageOnLogin(c *fiber.Ctx) error {
if auth.IsLoggedIn(c) {
return c.Redirect("/app/dashboard")
}
// Si tiene sesión de portal activa, ir al portal
if user, err := auth.PortalUser(c); err == nil && user != nil {
return c.Redirect("/portal/dashboard")
}
return c.Next()
}
@@ -28,6 +32,13 @@ func ValidateLoginPost(c *fiber.Ctx) error {
user, err := login.CheckLogin()
if err != nil {
// Si no está en users, intentar en portal_users
if portalUser, pErr := models.CheckPortalLogin(login.NombreUsuario, login.Password); pErr == nil {
if sErr := auth.SetPortalSession(c, portalUser.ID); sErr != nil {
return c.Redirect("/login?error=Error+interno")
}
return c.Redirect("/portal/dashboard")
}
return c.Redirect("/login?error=" + url.QueryEscape(err.Error()))
}