This commit is contained in:
Timothy J. Baek 2024-10-15 02:51:08 -07:00
parent 97bb9d41a6
commit b4cd503a02
2 changed files with 13 additions and 7 deletions

View File

@ -64,8 +64,10 @@ async def get_session_user(
expires_delta=expires_delta,
)
datetime_expires_at = datetime.datetime.fromtimestamp(
expires_at, datetime.timezone.utc
datetime_expires_at = (
datetime.datetime.fromtimestamp(expires_at, datetime.timezone.utc)
if expires_at
else None
)
# Set the cookie token
@ -193,8 +195,10 @@ async def signin(request: Request, response: Response, form_data: SigninForm):
expires_delta=expires_delta,
)
datetime_expires_at = datetime.datetime.fromtimestamp(
expires_at, datetime.timezone.utc
datetime_expires_at = (
datetime.datetime.fromtimestamp(expires_at, datetime.timezone.utc)
if expires_at
else None
)
# Set the cookie token
@ -276,8 +280,10 @@ async def signup(request: Request, response: Response, form_data: SignupForm):
expires_delta=expires_delta,
)
datetime_expires_at = datetime.datetime.fromtimestamp(
expires_at, datetime.timezone.utc
datetime_expires_at = (
datetime.datetime.fromtimestamp(expires_at, datetime.timezone.utc)
if expires_at
else None
)
# Set the cookie token

View File

@ -104,7 +104,7 @@ def get_current_user(
Users.update_user_last_active_by_id(user.id)
return user
else:
response.delete_cookie("token")
response.set_cookie("token", "", expires=0)
raise HTTPException(
status_code=status.HTTP_401_UNAUTHORIZED,