feat: combined admin dependency

org_or_super_admin_dependency can be used in place of org_admin_dependency to also allow super admins.
This commit is contained in:
Chris Milne 2026-05-19 11:08:22 +01:00
parent 34cb4414c9
commit 2b8296d622

View file

@ -126,7 +126,19 @@ async def is_super_admin(claims: claims_dependency):
super_admin_dependency = Annotated[dict[str, Any], Depends(is_super_admin)] super_admin_dependency = Annotated[dict[str, Any], Depends(is_super_admin)]
async def is_admin(claims: claims_dependency, db: db_dependency, org_id: int = Path(gt=0)):
try:
await is_super_admin(claims)
return True
except HTTPException as e:
pass
try:
await is_org_admin(claims, db, org_id)
return True
except HTTPException as e:
raise HTTPException(status_code=401, detail="Not authorised")
org_or_super_admin_dependency = Annotated[dict[str, Any], Depends(is_admin)]
# Middleware version of user auth # Middleware version of user auth
# import json # import json