mejora del portal
This commit is contained in:
@@ -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")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user