From 58cfa5b9c1894eaac548db22766a893840ff9194 Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Wed, 8 May 2024 16:19:59 -0700 Subject: [PATCH] fix: trusted header --- backend/apps/web/routers/auths.py | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/backend/apps/web/routers/auths.py b/backend/apps/web/routers/auths.py index 7a6fb2888..64f41fac5 100644 --- a/backend/apps/web/routers/auths.py +++ b/backend/apps/web/routers/auths.py @@ -118,23 +118,22 @@ async def signin(request: Request, form_data: SigninForm): ), ) user = Auths.authenticate_user_by_trusted_header(trusted_email) - - if WEBUI_AUTH == False: - - if Users.get_num_users() != 0: - raise HTTPException(400, detail=ERROR_MESSAGES.EXISTING_USERS) - - admin_email = "admin@localhost" - admin_password = "admin" - - if not Users.get_user_by_email(admin_email.lower()): - await signup( - request, - SignupForm(email=admin_email, password=admin_password, name="User"), - ) - user = Auths.authenticate_user(admin_email.lower(), admin_password) else: - user = Auths.authenticate_user(form_data.email.lower(), form_data.password) + if WEBUI_AUTH == False: + if Users.get_num_users() != 0: + raise HTTPException(400, detail=ERROR_MESSAGES.EXISTING_USERS) + + admin_email = "admin@localhost" + admin_password = "admin" + + if not Users.get_user_by_email(admin_email.lower()): + await signup( + request, + SignupForm(email=admin_email, password=admin_password, name="User"), + ) + user = Auths.authenticate_user(admin_email.lower(), admin_password) + else: + user = Auths.authenticate_user(form_data.email.lower(), form_data.password) if user: token = create_token(