feat: Add audit logging (#38189)

Co-authored-by: bircni <bircni@users.noreply.github.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
bircni
2026-09-12 10:15:23 +02:00
committed by GitHub
parent 4d43445532
commit da37b7916b
136 changed files with 3864 additions and 209 deletions
+5
View File
@@ -11,6 +11,7 @@ import (
"strconv"
"strings"
audit_model "gitea.dev/models/audit"
"gitea.dev/models/auth"
"gitea.dev/models/db"
org_model "gitea.dev/models/organization"
@@ -25,6 +26,7 @@ import (
"gitea.dev/modules/web"
"gitea.dev/routers/web/explore"
user_setting "gitea.dev/routers/web/user/setting"
"gitea.dev/services/audit"
auth_service "gitea.dev/services/auth"
"gitea.dev/services/context"
"gitea.dev/services/forms"
@@ -203,6 +205,8 @@ func NewUserPost(ctx *context.Context) {
ctx.Flash.Warning(ctx.Tr("form.email_domain_is_not_allowed", u.Email))
}
audit.Record(ctx, audit_model.UserCreate, u)
log.Trace("Account created by admin (%s): %s", ctx.Doer.Name, u.Name)
// Send email notification.
@@ -468,6 +472,7 @@ func ImpersonateUser(ctx *context.Context) {
ctx.ServerError("unable to impersonate user", err)
return
}
audit.Record(ctx, audit_model.UserImpersonation, u)
ctx.JSONRedirect(setting.AppSubURL + "/user/settings")
}