up
This commit is contained in:
@@ -40,12 +40,13 @@ func LoadPortalUsuarios(c *fiber.Ctx) error {
|
||||
|
||||
func CreatePortalUsuario(c *fiber.Ctx) error {
|
||||
type Req struct {
|
||||
Nombre string `json:"nombre"`
|
||||
Email string `json:"email"`
|
||||
Password string `json:"password"`
|
||||
ClienteID *uint `json:"cliente_id"`
|
||||
Rol string `json:"rol"`
|
||||
Notas string `json:"notas"`
|
||||
Nombre string `json:"nombre"`
|
||||
Email string `json:"email"`
|
||||
Password string `json:"password"`
|
||||
ClienteID *uint `json:"cliente_id"`
|
||||
Rol string `json:"rol"`
|
||||
Notas string `json:"notas"`
|
||||
TelegramChatID string `json:"telegram_chat_id"`
|
||||
}
|
||||
var req Req
|
||||
if err := c.BodyParser(&req); err != nil {
|
||||
@@ -62,13 +63,14 @@ func CreatePortalUsuario(c *fiber.Ctx) error {
|
||||
req.Rol = "cliente"
|
||||
}
|
||||
u := &models.PortalUser{
|
||||
Nombre: req.Nombre,
|
||||
Email: strings.ToLower(strings.TrimSpace(req.Email)),
|
||||
Password: hashed,
|
||||
ClienteID: req.ClienteID,
|
||||
Rol: req.Rol,
|
||||
Activo: true,
|
||||
Notas: req.Notas,
|
||||
Nombre: req.Nombre,
|
||||
Email: strings.ToLower(strings.TrimSpace(req.Email)),
|
||||
Password: hashed,
|
||||
ClienteID: req.ClienteID,
|
||||
Rol: req.Rol,
|
||||
Activo: true,
|
||||
Notas: req.Notas,
|
||||
TelegramChatID: req.TelegramChatID,
|
||||
}
|
||||
if err := models.CreatePortalUser(u); err != nil {
|
||||
return c.Status(500).JSON(fiber.Map{"error": err.Error()})
|
||||
@@ -83,25 +85,27 @@ func UpdatePortalUsuario(c *fiber.Ctx) error {
|
||||
return c.Status(400).JSON(fiber.Map{"error": "ID inválido"})
|
||||
}
|
||||
type Req struct {
|
||||
Nombre string `json:"nombre"`
|
||||
Email string `json:"email"`
|
||||
Password string `json:"password"`
|
||||
ClienteID *uint `json:"cliente_id"`
|
||||
Rol string `json:"rol"`
|
||||
Activo bool `json:"activo"`
|
||||
Notas string `json:"notas"`
|
||||
Nombre string `json:"nombre"`
|
||||
Email string `json:"email"`
|
||||
Password string `json:"password"`
|
||||
ClienteID *uint `json:"cliente_id"`
|
||||
Rol string `json:"rol"`
|
||||
Activo bool `json:"activo"`
|
||||
Notas string `json:"notas"`
|
||||
TelegramChatID string `json:"telegram_chat_id"`
|
||||
}
|
||||
var req Req
|
||||
if err := c.BodyParser(&req); err != nil {
|
||||
return c.Status(400).JSON(fiber.Map{"error": err.Error()})
|
||||
}
|
||||
u := &models.PortalUser{
|
||||
Nombre: req.Nombre,
|
||||
Email: strings.ToLower(strings.TrimSpace(req.Email)),
|
||||
ClienteID: req.ClienteID,
|
||||
Rol: req.Rol,
|
||||
Activo: req.Activo,
|
||||
Notas: req.Notas,
|
||||
Nombre: req.Nombre,
|
||||
Email: strings.ToLower(strings.TrimSpace(req.Email)),
|
||||
ClienteID: req.ClienteID,
|
||||
Rol: req.Rol,
|
||||
Activo: req.Activo,
|
||||
Notas: req.Notas,
|
||||
TelegramChatID: req.TelegramChatID,
|
||||
}
|
||||
u.ID = uint(id)
|
||||
if err := models.UpdatePortalUser(u); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user