backend authorization fix

This commit is contained in:
2024-04-08 13:33:18 +03:00
parent 10fbd6b1cb
commit 3594d9deca

View File

@ -83,10 +83,10 @@ async def get_current_user(
username: str = payload.get("sub")
if username is None:
raise credentials_exception
token_data = TokenData(username=username)
token_data = schemas.TokenData(username=username)
except JWTError:
raise credentials_exception
user = get_user(fake_users_db, username=token_data.username)
user = get_user_by_username(db, username=token_data.username)
if user is None:
raise credentials_exception
return user
@ -95,6 +95,6 @@ async def get_current_user(
async def get_current_active_user(
current_user: Annotated[schemas.User, Depends(get_current_user)],
):
if current_user.disabled:
if not current_user.is_active:
raise HTTPException(status_code=400, detail="Inactive user")
return current_user