mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-16 20:07:49 +01:00
refac: move things around, uplift oauth endpoints
This commit is contained in:
@@ -112,9 +112,16 @@ class UsersTable:
|
||||
except:
|
||||
return None
|
||||
|
||||
def get_user_by_email(self, email: str) -> Optional[UserModel]:
|
||||
def get_user_by_email(
|
||||
self, email: str, oauth_user: bool = False
|
||||
) -> Optional[UserModel]:
|
||||
try:
|
||||
user = User.get((User.email == email, User.oauth_sub.is_null()))
|
||||
conditions = (
|
||||
(User.email == email, User.oauth_sub.is_null())
|
||||
if not oauth_user
|
||||
else (User.email == email)
|
||||
)
|
||||
user = User.get(conditions)
|
||||
return UserModel(**model_to_dict(user))
|
||||
except:
|
||||
return None
|
||||
@@ -177,6 +184,18 @@ class UsersTable:
|
||||
except:
|
||||
return None
|
||||
|
||||
def update_user_oauth_sub_by_id(
|
||||
self, id: str, oauth_sub: str
|
||||
) -> Optional[UserModel]:
|
||||
try:
|
||||
query = User.update(oauth_sub=oauth_sub).where(User.id == id)
|
||||
query.execute()
|
||||
|
||||
user = User.get(User.id == id)
|
||||
return UserModel(**model_to_dict(user))
|
||||
except:
|
||||
return None
|
||||
|
||||
def update_user_by_id(self, id: str, updated: dict) -> Optional[UserModel]:
|
||||
try:
|
||||
query = User.update(**updated).where(User.id == id)
|
||||
|
||||
Reference in New Issue
Block a user