mirror of
https://github.com/open-webui/open-webui
synced 2024-11-26 05:51:12 +00:00
feat(sqlalchemy): some fixes
This commit is contained in:
parent
a9b148791d
commit
8f939cf55b
@ -185,6 +185,7 @@ class UsersTable:
|
||||
Session.query(User).filter_by(id=id).update(
|
||||
{"last_active_at": int(time.time())}
|
||||
)
|
||||
Session.commit()
|
||||
|
||||
user = Session.query(User).filter_by(id=id).first()
|
||||
return UserModel.model_validate(user)
|
||||
|
@ -794,11 +794,10 @@ app.add_middleware(
|
||||
)
|
||||
|
||||
@app.middleware("http")
|
||||
async def remove_session_after_request(request: Request, call_next):
|
||||
async def commit_session_after_request(request: Request, call_next):
|
||||
response = await call_next(request)
|
||||
log.debug("Removing session after request")
|
||||
log.debug("Commit session after request")
|
||||
Session.commit()
|
||||
Session.remove()
|
||||
return response
|
||||
|
||||
|
||||
|
@ -113,8 +113,8 @@ def get_current_user(
|
||||
)
|
||||
|
||||
|
||||
def get_current_user_by_api_key(db: Session, api_key: str):
|
||||
user = Users.get_user_by_api_key(db, api_key)
|
||||
def get_current_user_by_api_key(api_key: str):
|
||||
user = Users.get_user_by_api_key(api_key)
|
||||
|
||||
if user is None:
|
||||
raise HTTPException(
|
||||
@ -122,7 +122,7 @@ def get_current_user_by_api_key(db: Session, api_key: str):
|
||||
detail=ERROR_MESSAGES.INVALID_TOKEN,
|
||||
)
|
||||
else:
|
||||
Users.update_user_last_active_by_id(db, user.id)
|
||||
Users.update_user_last_active_by_id(user.id)
|
||||
|
||||
return user
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user