Skip to content

Commit

Permalink
Async to sync (#272)
Browse files Browse the repository at this point in the history
* refactor: replace async with sync in auth

* refactor: fix some wrong types

* Keep the async in login_for_access_token, refs #272

---------

Co-authored-by: redowan <[email protected]>
  • Loading branch information
kareemmahlees and rednafi authored Oct 21, 2023
1 parent 33fd73b commit 7579cf0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions app/core/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def get_password_hash(password: str) -> str:


def get_user(
db: dict[str, dict[str, str]],
db: dict[str, dict[str, Any]],
username: Optional[str],
) -> UserInDB | None:
if username not in db:
Expand All @@ -75,7 +75,7 @@ def authenticate_user(
return user


def create_access_token(data: dict, expires_delta: timedelta | None = None) -> bytes:
def create_access_token(data: dict, expires_delta: timedelta | None = None) -> str:
to_encode = data.copy()

if expires_delta:
Expand All @@ -92,7 +92,7 @@ def create_access_token(data: dict, expires_delta: timedelta | None = None) -> b
return encoded_jwt


async def get_current_user(token: str = Depends(oauth2_scheme)) -> UserInDB:
def get_current_user(token: str = Depends(oauth2_scheme)) -> UserInDB:
credentials_exception = HTTPException(
status_code=HTTPStatus.UNAUTHORIZED,
detail="Could not validate credentials",
Expand Down

0 comments on commit 7579cf0

Please sign in to comment.