ia ollama
This commit is contained in:
@@ -3,6 +3,8 @@ package controllers
|
||||
import (
|
||||
"time"
|
||||
|
||||
"net/url"
|
||||
|
||||
"github.com/gofiber/fiber/v2" //nolint:goimports
|
||||
"github.com/gofiber/fiber/v2/middleware/session"
|
||||
"github.com/sujit-baniya/fiber-boilerplate/app"
|
||||
@@ -19,30 +21,21 @@ func LoginGet(c *fiber.Ctx) error {
|
||||
func LoginPost(c *fiber.Ctx) error {
|
||||
// Verificar si falta la contraseña
|
||||
if c.Locals("missing_password") == true {
|
||||
return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{
|
||||
"status": "missing",
|
||||
"message": "no_password",
|
||||
})
|
||||
return c.Redirect("/update-credentials") // Redirige directamente
|
||||
}
|
||||
|
||||
// Obtener el usuario desde el contexto
|
||||
user := c.Locals("user").(*models.Users)
|
||||
|
||||
// Intentar realizar el login
|
||||
_, err := auth.Login(c, user.ID, app.Http.Token.AppJwtSecret) //nolint:wsl
|
||||
_, err := auth.Login(c, user.ID, app.Http.Token.AppJwtSecret)
|
||||
if err != nil {
|
||||
// Si ocurre un error, devolverlo en formato JSON
|
||||
return c.JSON(fiber.Map{
|
||||
"status": "error",
|
||||
"message": err.Error(),
|
||||
})
|
||||
// Si hay error, podrías mandar de nuevo al login con mensaje
|
||||
return c.Redirect("/login?error=" + url.QueryEscape(err.Error()))
|
||||
}
|
||||
|
||||
// Si todo está bien, devolver éxito y el token JWT
|
||||
return c.JSON(fiber.Map{
|
||||
"status": "success",
|
||||
"message": "Login exitoso",
|
||||
})
|
||||
// Si todo está bien, redirige al inicio de la app
|
||||
return c.Redirect("/app/servidor")
|
||||
}
|
||||
|
||||
var store = session.New()
|
||||
|
||||
Reference in New Issue
Block a user