mejora del portal

This commit is contained in:
Lizandro Guarnizo
2026-05-15 15:39:48 -05:00
parent d7fe292f05
commit 04fd456a4c
3 changed files with 14 additions and 1 deletions
+6
View File
@@ -2,6 +2,7 @@ package controllers
import (
"fmt"
"log"
"net/url"
"strings"
@@ -27,11 +28,14 @@ func PortalLoginPost(c *fiber.Ctx) error {
password := c.FormValue("password")
u, err := models.CheckPortalLogin(email, password)
if err != nil {
log.Printf("[PORTAL LOGIN] Fallo para %q: %v", email, err)
return c.Redirect("/portal/login?error=" + url.QueryEscape(err.Error()))
}
if err := auth.SetPortalSession(c, u.ID); err != nil {
log.Printf("[PORTAL LOGIN] Error guardando sesión para usuario %d: %v", u.ID, err)
return c.Redirect("/portal/login?error=Error+interno")
}
log.Printf("[PORTAL LOGIN] OK usuario %d (%s)", u.ID, email)
return c.Redirect("/portal/dashboard")
}
@@ -45,12 +49,14 @@ func PortalLogout(c *fiber.Ctx) error {
func PortalDashboard(c *fiber.Ctx) error {
u := middlewares.PortalUserFromLocals(c)
if u == nil {
log.Println("[PORTAL DASHBOARD] Usuario no en locals, redirigiendo a login")
return c.Redirect("/portal/login")
}
// Recargar con accesos
fullUser, err := models.GetPortalUserByID(u.ID)
if err != nil {
log.Printf("[PORTAL DASHBOARD] Error cargando usuario %d: %v", u.ID, err)
return c.Redirect("/portal/login")
}