FastAPI - Authentication and Security
Identify the error in this FastAPI role check dependency:
def check_admin(user: User = Depends(get_current_user)):
if user.role == 'admin':
return True
else:
return False
@app.get('/admin')
async def admin_panel(is_admin: bool = Depends(check_admin)):
if not is_admin:
raise HTTPException(status_code=403)
return {"msg": "Welcome admin"}