mirror of
https://github.com/open-webui/open-webui
synced 2025-06-26 18:26:48 +00:00
refac
This commit is contained in:
@@ -167,22 +167,6 @@ class AuthsTable:
|
||||
except:
|
||||
return False
|
||||
|
||||
def update_api_key_by_id(self, id: str, api_key: str) -> str:
|
||||
try:
|
||||
query = Auth.update(api_key=api_key).where(Auth.id == id)
|
||||
result = query.execute()
|
||||
|
||||
return True if result == 1 else False
|
||||
except:
|
||||
return False
|
||||
|
||||
def get_api_key_by_id(self, id: str) -> Optional[str]:
|
||||
try:
|
||||
auth = Auth.get(Auth.id == id)
|
||||
return auth.api_key
|
||||
except:
|
||||
return None
|
||||
|
||||
def delete_auth_by_id(self, id: str) -> bool:
|
||||
try:
|
||||
# Delete User
|
||||
|
||||
@@ -158,5 +158,21 @@ class UsersTable:
|
||||
except:
|
||||
return False
|
||||
|
||||
def update_user_api_key_by_id(self, id: str, api_key: str) -> str:
|
||||
try:
|
||||
query = User.update(api_key=api_key).where(User.id == id)
|
||||
result = query.execute()
|
||||
|
||||
return True if result == 1 else False
|
||||
except:
|
||||
return False
|
||||
|
||||
def get_user_api_key_by_id(self, id: str) -> Optional[str]:
|
||||
try:
|
||||
user = User.get(User.id == id)
|
||||
return user.api_key
|
||||
except:
|
||||
return None
|
||||
|
||||
|
||||
Users = UsersTable(DB)
|
||||
|
||||
Reference in New Issue
Block a user