feat: SAC 0.6.0 user edit UI, login to dashboard, daily report timer sync
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -32,6 +32,7 @@ class CreateUserRequest(BaseModel):
|
||||
|
||||
|
||||
class UpdateUserRequest(BaseModel):
|
||||
username: str | None = Field(default=None, min_length=2, max_length=64)
|
||||
role: str | None = None
|
||||
password: str | None = Field(default=None, min_length=8, max_length=128)
|
||||
is_active: bool | None = None
|
||||
@@ -91,6 +92,20 @@ def update_user(
|
||||
if user is None:
|
||||
raise HTTPException(status_code=404, detail="User not found")
|
||||
|
||||
if body.username is not None:
|
||||
normalized = body.username.strip()
|
||||
if not normalized:
|
||||
raise HTTPException(status_code=422, detail="username is required")
|
||||
existing = db.scalar(
|
||||
select(User).where(
|
||||
func.lower(User.username) == normalized.lower(),
|
||||
User.id != user.id,
|
||||
)
|
||||
)
|
||||
if existing is not None:
|
||||
raise HTTPException(status_code=400, detail="username already exists")
|
||||
user.username = normalized
|
||||
|
||||
if body.role is not None:
|
||||
if body.role not in USER_ROLES:
|
||||
raise HTTPException(status_code=422, detail=f"role must be one of: {', '.join(sorted(USER_ROLES))}")
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
"""Единый источник версии SAC (API, health, логи, OpenAPI)."""
|
||||
|
||||
APP_NAME = "Security Alert Center"
|
||||
APP_VERSION = "0.5.0"
|
||||
APP_VERSION = "0.6.0"
|
||||
APP_VERSION_LABEL = f"{APP_NAME} v.{APP_VERSION}"
|
||||
|
||||
Reference in New Issue
Block a user