check user is admin
This commit is contained in:
parent
a35aaa388c
commit
e76de17ff5
1 changed files with 10 additions and 1 deletions
|
@ -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}
|
||||
|
|
Loading…
Reference in a new issue