@@ -98,9 +98,10 @@ func (h *Handlers) settingsGeneralUpdate(w http.ResponseWriter, r *http.Request) |
| 98 | 98 | } |
| 99 | 99 | } |
| 100 | 100 | viewer := middleware.CurrentUserFromContext(r.Context()) |
| 101 | | - _ = h.d.Audit.Record(r.Context(), h.d.Pool, viewer.ID, |
| 101 | + auditActor, auditMeta := viewer.AuditActor(map[string]any{"action": "general_settings_updated"}) |
| 102 | + _ = h.d.Audit.Record(r.Context(), h.d.Pool, auditActor, |
| 102 | 103 | audit.ActionRepoCreated, audit.TargetRepo, row.ID, |
| 103 | | - map[string]any{"action": "general_settings_updated"}) |
| 104 | + auditMeta) |
| 104 | 105 | |
| 105 | 106 | http.Redirect(w, r, "/"+owner.Username+"/"+row.Name+"/settings/general?notice=saved", http.StatusSeeOther) |
| 106 | 107 | } |
@@ -152,9 +153,10 @@ func (h *Handlers) settingsMergeUpdate(w http.ResponseWriter, r *http.Request) { |
| 152 | 153 | return |
| 153 | 154 | } |
| 154 | 155 | viewer := middleware.CurrentUserFromContext(r.Context()) |
| 155 | | - _ = h.d.Audit.Record(r.Context(), h.d.Pool, viewer.ID, |
| 156 | + auditActor, auditMeta := viewer.AuditActor(map[string]any{"action": "merge_settings_updated"}) |
| 157 | + _ = h.d.Audit.Record(r.Context(), h.d.Pool, auditActor, |
| 156 | 158 | audit.ActionRepoCreated, audit.TargetRepo, row.ID, |
| 157 | | - map[string]any{"action": "merge_settings_updated"}) |
| 159 | + auditMeta) |
| 158 | 160 | |
| 159 | 161 | http.Redirect(w, r, "/"+owner.Username+"/"+row.Name+"/settings/general?notice=saved", http.StatusSeeOther) |
| 160 | 162 | } |
@@ -229,9 +231,10 @@ func (h *Handlers) settingsCollabUpsert(w http.ResponseWriter, r *http.Request) |
| 229 | 231 | return |
| 230 | 232 | } |
| 231 | 233 | policy.InvalidateRepo(r.Context(), row.ID) |
| 232 | | - _ = h.d.Audit.Record(r.Context(), h.d.Pool, viewer.ID, |
| 234 | + auditActor, auditMeta := viewer.AuditActor(map[string]any{"action": "collaborator_added", "user": username, "role": string(role)}) |
| 235 | + _ = h.d.Audit.Record(r.Context(), h.d.Pool, auditActor, |
| 233 | 236 | audit.ActionRepoCreated, audit.TargetRepo, row.ID, |
| 234 | | - map[string]any{"action": "collaborator_added", "user": username, "role": string(role)}) |
| 237 | + auditMeta) |
| 235 | 238 | http.Redirect(w, r, "/"+owner.Username+"/"+row.Name+"/settings/access?notice=saved", http.StatusSeeOther) |
| 236 | 239 | } |
| 237 | 240 | |
@@ -259,9 +262,10 @@ func (h *Handlers) settingsCollabRemove(w http.ResponseWriter, r *http.Request) |
| 259 | 262 | } |
| 260 | 263 | policy.InvalidateRepo(r.Context(), row.ID) |
| 261 | 264 | viewer := middleware.CurrentUserFromContext(r.Context()) |
| 262 | | - _ = h.d.Audit.Record(r.Context(), h.d.Pool, viewer.ID, |
| 265 | + auditActor, auditMeta := viewer.AuditActor(map[string]any{"action": "collaborator_removed", "user_id": uid}) |
| 266 | + _ = h.d.Audit.Record(r.Context(), h.d.Pool, auditActor, |
| 263 | 267 | audit.ActionRepoCreated, audit.TargetRepo, row.ID, |
| 264 | | - map[string]any{"action": "collaborator_removed", "user_id": uid}) |
| 268 | + auditMeta) |
| 265 | 269 | http.Redirect(w, r, "/"+owner.Username+"/"+row.Name+"/settings/access?notice=saved", http.StatusSeeOther) |
| 266 | 270 | } |
| 267 | 271 | |
@@ -306,9 +310,10 @@ func (h *Handlers) settingsTeamGrant(w http.ResponseWriter, r *http.Request) { |
| 306 | 310 | return |
| 307 | 311 | } |
| 308 | 312 | policy.InvalidateRepo(r.Context(), row.ID) |
| 309 | | - _ = h.d.Audit.Record(r.Context(), h.d.Pool, viewer.ID, |
| 313 | + auditActor, auditMeta := viewer.AuditActor(map[string]any{"action": "team_grant_added", "team_id": teamID, "role": string(role)}) |
| 314 | + _ = h.d.Audit.Record(r.Context(), h.d.Pool, auditActor, |
| 310 | 315 | audit.ActionRepoCreated, audit.TargetRepo, row.ID, |
| 311 | | - map[string]any{"action": "team_grant_added", "team_id": teamID, "role": string(role)}) |
| 316 | + auditMeta) |
| 312 | 317 | http.Redirect(w, r, "/"+owner.Username+"/"+row.Name+"/settings/access?notice=saved", http.StatusSeeOther) |
| 313 | 318 | } |
| 314 | 319 | |
@@ -340,9 +345,10 @@ func (h *Handlers) settingsTeamRevoke(w http.ResponseWriter, r *http.Request) { |
| 340 | 345 | } |
| 341 | 346 | policy.InvalidateRepo(r.Context(), row.ID) |
| 342 | 347 | viewer := middleware.CurrentUserFromContext(r.Context()) |
| 343 | | - _ = h.d.Audit.Record(r.Context(), h.d.Pool, viewer.ID, |
| 348 | + auditActor, auditMeta := viewer.AuditActor(map[string]any{"action": "team_grant_removed", "team_id": teamID}) |
| 349 | + _ = h.d.Audit.Record(r.Context(), h.d.Pool, auditActor, |
| 344 | 350 | audit.ActionRepoCreated, audit.TargetRepo, row.ID, |
| 345 | | - map[string]any{"action": "team_grant_removed", "team_id": teamID}) |
| 351 | + auditMeta) |
| 346 | 352 | http.Redirect(w, r, "/"+owner.Username+"/"+row.Name+"/settings/access?notice=saved", http.StatusSeeOther) |
| 347 | 353 | } |
| 348 | 354 | |