feat: auth dependency for root user with org in body
This commit is contained in:
parent
36736e5142
commit
51bb48372c
1 changed files with 11 additions and 1 deletions
|
|
@ -13,7 +13,7 @@ from typing import Annotated
|
||||||
from fastapi import Depends
|
from fastapi import Depends
|
||||||
|
|
||||||
from src.user.dependencies import user_model_claims_dependency
|
from src.user.dependencies import user_model_claims_dependency
|
||||||
from src.organisation.dependencies import org_model_query_dependency
|
from src.organisation.dependencies import org_model_query_dependency, org_model_body_dependency
|
||||||
from src.organisation.models import Organisation as Org
|
from src.organisation.models import Organisation as Org
|
||||||
|
|
||||||
from src.auth.exceptions import UnauthorizedException
|
from src.auth.exceptions import UnauthorizedException
|
||||||
|
|
@ -39,6 +39,16 @@ async def org_query_root_claims(user_model: user_model_claims_dependency, org_mo
|
||||||
org_model_root_claim_query_dependency = Annotated[type[Org], Depends(org_query_root_claims)]
|
org_model_root_claim_query_dependency = Annotated[type[Org], Depends(org_query_root_claims)]
|
||||||
|
|
||||||
|
|
||||||
|
async def org_body_root_claims(user_model: user_model_claims_dependency, org_model: org_model_body_dependency):
|
||||||
|
if org_model.root_user_id == user_model.id:
|
||||||
|
return org_model
|
||||||
|
|
||||||
|
raise UnauthorizedException()
|
||||||
|
|
||||||
|
|
||||||
|
org_model_root_claim_body_dependency = Annotated[type[Org], Depends(org_body_root_claims)]
|
||||||
|
|
||||||
|
|
||||||
async def is_super_admin(user_model: user_model_claims_dependency):
|
async def is_super_admin(user_model: user_model_claims_dependency):
|
||||||
super_admin_emails = []
|
super_admin_emails = []
|
||||||
if user_model.email not in super_admin_emails:
|
if user_model.email not in super_admin_emails:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue