Fix #515: remove calls to deprecated user callables in internal codebase

This commit is contained in:
François Voron
2021-03-04 17:50:19 +01:00
parent c41b4d1bd4
commit 8eb53f4744
3 changed files with 14 additions and 13 deletions

View File

@ -15,10 +15,9 @@ def get_auth_router(
) -> APIRouter:
"""Generate a router with login/logout routes for an authentication backend."""
router = APIRouter()
if requires_verification:
get_current_user = authenticator.get_current_verified_user
else:
get_current_user = authenticator.get_current_active_user
get_current_user = authenticator.current_user(
active=True, verified=requires_verification
)
@router.post("/login")
async def login(

View File

@ -22,12 +22,12 @@ def get_users_router(
"""Generate a router with the authentication routes."""
router = APIRouter()
if requires_verification:
get_current_active_user = authenticator.get_current_verified_user
get_current_superuser = authenticator.get_current_verified_superuser
else:
get_current_active_user = authenticator.get_current_active_user
get_current_superuser = authenticator.get_current_superuser
get_current_active_user = authenticator.current_user(
active=True, verified=requires_verification
)
get_current_superuser = authenticator.current_user(
active=True, verified=requires_verification, superuser=True
)
async def _get_or_404(id: UUID4) -> models.BaseUserDB:
user = await user_db.get(id)