feat: add WEBUI_AUTH_TRUSTED_EMAIL_HEADER for authenticating users by a trusted header

This is very yolo code, use at your own risk
This commit is contained in:
Jun Siang Cheah 2024-03-26 21:30:53 +00:00 committed by Jun Siang Cheah
parent 7d45d2762f
commit 29f13f34d3
8 changed files with 58 additions and 13 deletions

View file

@ -122,6 +122,17 @@ class AuthsTable:
except:
return None
def authenticate_user_by_trusted_header(self,
email: str) -> Optional[UserModel]:
log.info(f"authenticate_user_by_trusted_header: {email}")
try:
auth = Auth.get(Auth.email == email, Auth.active == True)
if auth:
user = Users.get_user_by_id(auth.id)
return user
except:
return None
def update_user_password_by_id(self, id: str, new_password: str) -> bool:
try:
query = Auth.update(password=new_password).where(Auth.id == id)