Update login.go
This commit is contained in:
@@ -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()))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user