mirror of
https://github.com/rzmk/learnhouse.git
synced 2025-12-19 04:19:25 +00:00
🔒️ roles : organizations support
This commit is contained in:
parent
90234bc5d7
commit
73e25c4b37
5 changed files with 16 additions and 30 deletions
|
|
@ -116,6 +116,7 @@ async def delete_org(org_id: str, current_user: User):
|
|||
|
||||
|
||||
async def get_orgs(page: int = 1, limit: int = 10):
|
||||
## TODO : auth
|
||||
await check_database()
|
||||
orgs = learnhouseDB["orgs"]
|
||||
|
||||
|
|
@ -127,7 +128,7 @@ async def get_orgs(page: int = 1, limit: int = 10):
|
|||
|
||||
#### Security ####################################################
|
||||
|
||||
async def verify_org_rights(org_id: str, current_user: User):
|
||||
async def verify_org_rights(org_id: str, current_user: User, action:str,):
|
||||
await check_database()
|
||||
orgs = learnhouseDB["organizations"]
|
||||
|
||||
|
|
@ -137,10 +138,10 @@ async def verify_org_rights(org_id: str, current_user: User):
|
|||
raise HTTPException(
|
||||
status_code=status.HTTP_409_CONFLICT, detail="Organization does not exist")
|
||||
|
||||
isAdmin = current_user.username in org["admins"]
|
||||
isOwner = current_user.username in org["owners"]
|
||||
hasRoleRights = await verify_user_rights_with_roles(action,current_user.username,org_id)
|
||||
|
||||
if not isAdmin and not isOwner:
|
||||
if not hasRoleRights and not isOwner:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_403_FORBIDDEN, detail="You do not have rights to this organization")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue