forked from open-webui/open-webui
refac
This commit is contained in:
parent
ba0523cd69
commit
da8646cae9
3 changed files with 19 additions and 19 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue