Initial commit
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"github.com/gofiber/fiber/v2"
|
||||
)
|
||||
|
||||
func Profile(c *fiber.Ctx) error {
|
||||
// Obtiene el usuario del contexto en formato map[string]interface{}
|
||||
user, ok := c.Locals("user").(map[string]interface{})
|
||||
if !ok || user == nil {
|
||||
return c.Status(fiber.StatusUnauthorized).JSON(fiber.Map{
|
||||
"message": "Usuario no autenticado",
|
||||
})
|
||||
}
|
||||
|
||||
// Obtener el usuario del contexto
|
||||
// Renderiza la vista "profile" pasando el usuario
|
||||
if err := c.Render("profile", fiber.Map{
|
||||
"user": user,
|
||||
}, "layouts/main"); err != nil {
|
||||
return c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{
|
||||
"message": "Error rendering template",
|
||||
"error": err.Error(),
|
||||
})
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user