From c6882a0598df9805b86293949f93c0ff25e161cd Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Mon, 25 Sep 2023 20:56:39 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(login.py):=20move=20user=20a?= =?UTF-8?q?uthentication=20logic=20outside=20of=20try-except=20block=20to?= =?UTF-8?q?=20ensure=20proper=20error=20handling=20=E2=9C=A8=20feat(login.?= =?UTF-8?q?py):=20add=20endpoint=20for=20auto=20login=20to=20improve=20use?= =?UTF-8?q?r=20experience?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/langflow/api/v1/login.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/backend/langflow/api/v1/login.py b/src/backend/langflow/api/v1/login.py index e33eb8225..6888d4718 100644 --- a/src/backend/langflow/api/v1/login.py +++ b/src/backend/langflow/api/v1/login.py @@ -25,21 +25,21 @@ async def login_to_get_access_token( ): try: user = authenticate_user(form_data.username, form_data.password, db) - - if user: - return create_user_tokens(user_id=user.id, db=db, update_last_login=True) - else: - raise HTTPException( - status_code=status.HTTP_401_UNAUTHORIZED, - detail="Incorrect username or password", - headers={"WWW-Authenticate": "Bearer"}, - ) except Exception as exc: raise HTTPException( status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, detail=str(exc), ) from exc + if user: + return create_user_tokens(user_id=user.id, db=db, update_last_login=True) + else: + raise HTTPException( + status_code=status.HTTP_401_UNAUTHORIZED, + detail="Incorrect username or password", + headers={"WWW-Authenticate": "Bearer"}, + ) + @router.get("/auto_login") async def auto_login(