Skip to content

Commit

Permalink
fix: catch user info is null (#213)
Browse files Browse the repository at this point in the history
  • Loading branch information
RaoHai authored Aug 18, 2024
2 parents 02cc6c9 + 37bd790 commit 1a3d112
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions server/auth/get_user_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,14 @@ async def getAnonymousUserInfoByToken(token: str):
return rows.data[0] if (len(rows.data) > 0) else None

async def get_user_access_token(petercat_user_token: Annotated[str | None, Cookie()] = None):
if petercat_user_token is None:
return None
user_info = await getUserInfoByToken(petercat_user_token)
if user_info is None:
try:
if petercat_user_token is None:
return None
user_info = await getUserInfoByToken(petercat_user_token)
if user_info is None:
return None
access_token = await getUserAccessToken(user_id=user_info['id'])
print(f"get_user_access_token: user_info={user_info}, access_token={access_token}")
return access_token
except Exception as e:
return None
access_token = await getUserAccessToken(user_id=user_info['id'])
print(f"get_user_access_token: user_info={user_info}, access_token={access_token}")
return access_token

0 comments on commit 1a3d112

Please sign in to comment.