Lege Einstellungen je Konto mit Erbung vom Hauptnutzer an und biete die Prüfstufe für doppelte Dokumente in Mein Konto an.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
bee48bf4a5
commit
a6dc24d8fe
11 files changed
+339
-1
No files matched your search
@@ -0,0 +1,41 @@
|
||||
"""Account preferences: read the effective value, change the own value, bind the team."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from fastapi import APIRouter, Depends
|
||||
from fastapi.responses import JSONResponse
|
||||
from psycopg import Connection
|
||||
|
||||
from app.access.policy import audit
|
||||
from app.api.deps import Principal, get_conn, get_principal
|
||||
from app.api.schemas import PreferenceIn
|
||||
from app.preferences import preference_state, store_preference
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
_NO_STORE = {"Cache-Control": "no-store"}
|
||||
|
||||
|
||||
@router.get("/api/v1/auth/preferences/{key}")
|
||||
def get_preference(key: str, principal: Principal = Depends(get_principal), conn: Connection = Depends(get_conn)):
|
||||
return JSONResponse(preference_state(conn, principal.account_id, key), headers=_NO_STORE)
|
||||
|
||||
|
||||
@router.put("/api/v1/auth/preferences/{key}")
|
||||
def put_preference(
|
||||
key: str,
|
||||
body: PreferenceIn,
|
||||
principal: Principal = Depends(get_principal),
|
||||
conn: Connection = Depends(get_conn),
|
||||
):
|
||||
state = store_preference(conn, principal.account_id, key, body.value, body.team_mode)
|
||||
audit(
|
||||
conn,
|
||||
principal.account_id,
|
||||
None,
|
||||
"preference_changed",
|
||||
"account",
|
||||
principal.account_id,
|
||||
detail={"key": key, "value": body.value, "team_mode": body.team_mode},
|
||||
)
|
||||
return JSONResponse(state, headers=_NO_STORE)
|
||||
Reference in new issue
Block a user