check user is admin

This commit is contained in:
Jörn-Michael Miehe 2022-03-15 17:38:31 +00:00
parent a35aaa388c
commit e76de17ff5

View file

@ -49,6 +49,15 @@ async def get_current_user(token: str = Depends(SCHEME)):
return user
@router.get("/current", response_model=User)
@router.get("/current_user/get", response_model=User)
async def get_current_user(current_user: User = Depends(get_current_user)):
return current_user
async def is_admin(current_user: User = Depends(get_current_user)):
return ("admin" in current_user.capabilities)
@router.get("/current_user/is_admin")
async def current_user_is_admin(is_admin: bool = Depends(is_admin)):
return {"is_admin": is_admin}