18 lines
525 B
Python
18 lines
525 B
Python
from fastapi import (
|
|
HTTPException,
|
|
status,
|
|
)
|
|
from api.db.logic.account import get_user_by_login
|
|
from api.db.tables.account import AccountRole
|
|
|
|
|
|
|
|
async def db_user_role_validation(connection, current_user):
|
|
|
|
authorize_user = await get_user_by_login(connection, current_user)
|
|
if authorize_user.role not in {AccountRole.OWNER, AccountRole.ADMIN}:
|
|
raise HTTPException(
|
|
status_code=status.HTTP_403_FORBIDDEN,
|
|
detail="You do not have enough permissions")
|
|
return authorize_user
|