Changeset 0.8.2 (#45)
This commit is contained in:
@@ -189,6 +189,9 @@ func (h *AdminHandler) CreateUser(c *gin.Context) {
|
||||
}
|
||||
|
||||
c.JSON(http.StatusCreated, user)
|
||||
AuditLog(c, "user.create", "user", user.ID, map[string]interface{}{
|
||||
"username": req.Username, "email": req.Email, "role": req.Role,
|
||||
})
|
||||
}
|
||||
|
||||
// ── Reset Password (admin) ──────────────────
|
||||
@@ -258,6 +261,7 @@ func (h *AdminHandler) UpdateUserRole(c *gin.Context) {
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{"message": "role updated", "role": req.Role})
|
||||
AuditLog(c, "user.role_change", "user", targetID, map[string]interface{}{"role": req.Role})
|
||||
}
|
||||
|
||||
// ── Toggle User Active ──────────────────────
|
||||
@@ -316,6 +320,13 @@ func (h *AdminHandler) ToggleUserActive(c *gin.Context) {
|
||||
"is_active": req.IsActive,
|
||||
"teams_assigned": teamsAssigned,
|
||||
})
|
||||
action := "user.activate"
|
||||
if !req.IsActive {
|
||||
action = "user.deactivate"
|
||||
}
|
||||
AuditLog(c, action, "user", targetID, map[string]interface{}{
|
||||
"is_active": req.IsActive, "teams_assigned": teamsAssigned,
|
||||
})
|
||||
}
|
||||
|
||||
// ── Delete User ─────────────────────────────
|
||||
@@ -341,6 +352,7 @@ func (h *AdminHandler) DeleteUser(c *gin.Context) {
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{"message": "user deleted"})
|
||||
AuditLog(c, "user.delete", "user", targetID, nil)
|
||||
}
|
||||
|
||||
// ── Public Settings (for any authenticated user) ──
|
||||
|
||||
Reference in New Issue
Block a user