Files
beabigegg 96210c7ad4 fix: sync user name from external auth API and fix audit log schema
- Auth router: Extract user name from nested data.userInfo.name structure
- Auth router: Sync user name on every login (not just on user creation)
- Audit schema: Change changes field type to Optional[Any] to support
  both list and dict formats (fixes 500 error on audit page)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-10 10:12:35 +08:00

62 lines
1.3 KiB
Python

from datetime import datetime
from typing import Optional, List, Any
from pydantic import BaseModel
class AuditLogResponse(BaseModel):
id: str
event_type: str
resource_type: str
resource_id: Optional[str]
user_id: Optional[str]
action: str
changes: Optional[Any] # Can be List[dict] or dict depending on event type
request_metadata: Optional[dict]
sensitivity_level: str
checksum: str
created_at: datetime
user_name: Optional[str] = None
user_email: Optional[str] = None
class Config:
from_attributes = True
class AuditLogListResponse(BaseModel):
logs: List[AuditLogResponse]
total: int
offset: int
limit: int
class AuditAlertResponse(BaseModel):
id: str
audit_log_id: str
alert_type: str
recipients: List[str]
message: Optional[str]
is_acknowledged: bool
acknowledged_by: Optional[str]
acknowledged_at: Optional[datetime]
created_at: datetime
class Config:
from_attributes = True
class AuditAlertListResponse(BaseModel):
alerts: List[AuditAlertResponse]
total: int
class IntegrityCheckRequest(BaseModel):
start_date: datetime
end_date: datetime
class IntegrityCheckResponse(BaseModel):
total_checked: int
valid_count: int
invalid_count: int
invalid_records: List[str]