feat(server): audit log filter accepts several actions
GET /api/v1/audit?action=login,login_failed lists sign-ins with failed attempts (AuditRepository.ListByActionsAsync). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
2 files changed
+12
-5
No files matched your search
@@ -81,10 +81,11 @@ public static class AdminEndpoints
|
||||
return Results.Json(store.Current(), ProtocolJson.Default.ServerSettingsDto);
|
||||
}
|
||||
|
||||
/// <summary>The audit log, newest first; <c>action</c> may list several actions separated by commas (<c>login,login_failed</c>).</summary>
|
||||
private static async Task<IResult> AuditAsync(HttpContext context, TitanoDatabase db, Guid? user, string? action, string? cursor, int? limit)
|
||||
{
|
||||
var page = await db.Audit.ListAsync(user, string.IsNullOrWhiteSpace(action) ? null : action, limit ?? 100,
|
||||
string.IsNullOrEmpty(cursor) ? null : cursor, context.RequestAborted);
|
||||
var actions = (action ?? string.Empty).Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
|
||||
var page = await db.Audit.ListByActionsAsync(user, actions, limit ?? 100, string.IsNullOrEmpty(cursor) ? null : cursor, context.RequestAborted);
|
||||
return Results.Json(new Page<AuditEntryDto>([.. page.Items.Select(Dto.Audit)], page.NextCursor, null), ProtocolJson.Default.PageAuditEntryDto);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user