This commit is contained in:
Lizandro Guarnizo
2026-05-15 15:47:49 -05:00
parent 04fd456a4c
commit f7e8d273d2
2 changed files with 6 additions and 2 deletions
+3 -1
View File
@@ -7,11 +7,13 @@ import (
)
// PortalAuth protege las rutas del portal de clientes.
// Si no hay sesión activa, redirige a /portal/login.
// Si no hay sesión válida, destruye la sesión obsoleta y redirige a /portal/login.
func PortalAuth() fiber.Handler {
return func(c *fiber.Ctx) error {
user, err := auth.PortalUser(c)
if err != nil || user == nil {
// Limpiar sesión inválida/obsoleta para romper posibles redirect loops
_ = auth.DestroyPortalSession(c)
return c.Redirect("/portal/login")
}
c.Locals("portalUser", user)