feat(users): reemplazar confirmación por envío de credenciales con link de reset
- Eliminar envío automático de confirmación al crear usuario - Nuevo botón en cada fila: enviar credenciales (usuario + link establecer contraseña) - POST /app/users/:id/credenciales → SendUserCredencialesEmail - Email incluye username, link al login y link para establecer contraseña Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
bf3cbd3606
commit
107178aa97
@@ -486,9 +486,6 @@ func CreateUserGas(c *fiber.Ctx) error {
|
||||
})
|
||||
}
|
||||
|
||||
// Envía un correo de confirmación
|
||||
go services.SendConfirmationEmail(m.Email, services.GetPublicURL(), m.NombreUsuario)
|
||||
|
||||
return c.Status(fiber.StatusCreated).JSON(fiber.Map{
|
||||
"message": "Usuario creado con éxito",
|
||||
"error": false,
|
||||
@@ -555,3 +552,19 @@ func createPassword(c *fiber.Ctx, UserId uint) error {
|
||||
"error": false,
|
||||
})
|
||||
}
|
||||
|
||||
func EnviarCredencialesUsuario(c *fiber.Ctx) error {
|
||||
id, err := strconv.ParseUint(c.Params("id"), 10, 32)
|
||||
if err != nil {
|
||||
return c.Status(400).JSON(fiber.Map{"error": "ID inválido"})
|
||||
}
|
||||
user, err := models.FindUserByID(uint(id))
|
||||
if err != nil || user == nil {
|
||||
return c.Status(404).JSON(fiber.Map{"error": "Usuario no encontrado"})
|
||||
}
|
||||
if user.Email == "" {
|
||||
return c.Status(400).JSON(fiber.Map{"error": "El usuario no tiene email registrado"})
|
||||
}
|
||||
go services.SendUserCredencialesEmail(user.Email, user.Name, user.NombreUsuario)
|
||||
return c.JSON(fiber.Map{"ok": true, "message": "Credenciales enviadas a " + user.Email})
|
||||
}
|
||||
|
||||
@@ -54,6 +54,7 @@ func UserRoutes(app fiber.Router) {
|
||||
protected.Put("/password/:id", controllers.UpdatePassword) // Actualizar
|
||||
protected.Delete("/users/:id", controllers.DeleteUser) // Eliminar
|
||||
protected.Get("/user/:id", controllers.GetUser) // Buscar un usuario
|
||||
protected.Post("/users/:id/credenciales", controllers.EnviarCredencialesUsuario) // Enviar credenciales
|
||||
|
||||
// Rutas de conexiones ssh
|
||||
protected.Get("/conexion_ssh", middlewares.MenuMiddleware, controllers.ConxSsh) // Renderizar la vista
|
||||
|
||||
Reference in New Issue
Block a user