47 lines
1.2 KiB
Python
47 lines
1.2 KiB
Python
from typing import Literal
|
|
|
|
from pydantic import BaseModel, EmailStr, Field, field_validator
|
|
|
|
from app.core.password_policy import validate_password_strength
|
|
|
|
|
|
class AdminUserPatchIn(BaseModel):
|
|
role: Literal["user", "admin"] | None = None
|
|
status: Literal["pending", "active", "blocked"] | None = None
|
|
is_superuser: bool | None = None
|
|
|
|
|
|
class AdminUserCreateIn(BaseModel):
|
|
email: EmailStr
|
|
password: str = Field(min_length=8)
|
|
role: Literal["user", "admin"] = "user"
|
|
is_superuser: bool = False
|
|
status: Literal["pending", "active", "blocked"] = "active"
|
|
|
|
@field_validator("password")
|
|
@classmethod
|
|
def password_policy(cls, value: str) -> str:
|
|
return validate_password_strength(value)
|
|
|
|
|
|
class AdminUserPasswordPatchIn(BaseModel):
|
|
password: str = Field(min_length=8)
|
|
|
|
@field_validator("password")
|
|
@classmethod
|
|
def password_policy(cls, value: str) -> str:
|
|
return validate_password_strength(value)
|
|
|
|
|
|
class AdminSettingsPatchIn(BaseModel):
|
|
values: dict
|
|
|
|
|
|
class AdminUiActivityIn(BaseModel):
|
|
event: str
|
|
meta: dict | None = None
|
|
|
|
|
|
class AdminRevealSecretIn(BaseModel):
|
|
key: Literal["database_password", "jwt_access_secret", "jwt_refresh_pepper", "s3_secret_key"]
|