forked from open-webui/open-webui
refac: api_key field moved to user
This commit is contained in:
parent
38c34b4444
commit
ba0523cd69
3 changed files with 59 additions and 9 deletions
|
@ -25,7 +25,6 @@ class Auth(Model):
|
|||
email = CharField()
|
||||
password = CharField()
|
||||
active = BooleanField()
|
||||
api_key = CharField(null=True, unique=True)
|
||||
|
||||
class Meta:
|
||||
database = DB
|
||||
|
@ -36,7 +35,6 @@ class AuthModel(BaseModel):
|
|||
email: str
|
||||
password: str
|
||||
active: bool = True
|
||||
api_key: Optional[str] = None
|
||||
|
||||
|
||||
####################
|
||||
|
@ -136,13 +134,8 @@ class AuthsTable:
|
|||
return None
|
||||
|
||||
try:
|
||||
auth = Auth.get(Auth.api_key == api_key, Auth.active == True)
|
||||
if auth:
|
||||
user = Users.get_user_by_id(auth.id)
|
||||
return user
|
||||
else:
|
||||
return None
|
||||
|
||||
user = Users.get_user_by_api_key(api_key)
|
||||
return user if user else None
|
||||
except:
|
||||
return False
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue