mirror of
https://github.com/open-webui/open-webui
synced 2025-05-29 09:42:12 +00:00
refac
This commit is contained in:
parent
97bb9d41a6
commit
b4cd503a02
@ -64,8 +64,10 @@ async def get_session_user(
|
|||||||
expires_delta=expires_delta,
|
expires_delta=expires_delta,
|
||||||
)
|
)
|
||||||
|
|
||||||
datetime_expires_at = datetime.datetime.fromtimestamp(
|
datetime_expires_at = (
|
||||||
expires_at, datetime.timezone.utc
|
datetime.datetime.fromtimestamp(expires_at, datetime.timezone.utc)
|
||||||
|
if expires_at
|
||||||
|
else None
|
||||||
)
|
)
|
||||||
|
|
||||||
# Set the cookie token
|
# Set the cookie token
|
||||||
@ -193,8 +195,10 @@ async def signin(request: Request, response: Response, form_data: SigninForm):
|
|||||||
expires_delta=expires_delta,
|
expires_delta=expires_delta,
|
||||||
)
|
)
|
||||||
|
|
||||||
datetime_expires_at = datetime.datetime.fromtimestamp(
|
datetime_expires_at = (
|
||||||
expires_at, datetime.timezone.utc
|
datetime.datetime.fromtimestamp(expires_at, datetime.timezone.utc)
|
||||||
|
if expires_at
|
||||||
|
else None
|
||||||
)
|
)
|
||||||
|
|
||||||
# Set the cookie token
|
# Set the cookie token
|
||||||
@ -276,8 +280,10 @@ async def signup(request: Request, response: Response, form_data: SignupForm):
|
|||||||
expires_delta=expires_delta,
|
expires_delta=expires_delta,
|
||||||
)
|
)
|
||||||
|
|
||||||
datetime_expires_at = datetime.datetime.fromtimestamp(
|
datetime_expires_at = (
|
||||||
expires_at, datetime.timezone.utc
|
datetime.datetime.fromtimestamp(expires_at, datetime.timezone.utc)
|
||||||
|
if expires_at
|
||||||
|
else None
|
||||||
)
|
)
|
||||||
|
|
||||||
# Set the cookie token
|
# Set the cookie token
|
||||||
|
@ -104,7 +104,7 @@ def get_current_user(
|
|||||||
Users.update_user_last_active_by_id(user.id)
|
Users.update_user_last_active_by_id(user.id)
|
||||||
return user
|
return user
|
||||||
else:
|
else:
|
||||||
response.delete_cookie("token")
|
response.set_cookie("token", "", expires=0)
|
||||||
|
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=status.HTTP_401_UNAUTHORIZED,
|
status_code=status.HTTP_401_UNAUTHORIZED,
|
||||||
|
Loading…
Reference in New Issue
Block a user