From eadf75ad24bd7a3ab06989a85f385e50a7fcc5bb Mon Sep 17 00:00:00 2001 From: Joe <1264204425@qq.com> Date: Mon, 2 Sep 2024 11:08:36 +0800 Subject: [PATCH] feat: add login account not found --- api/controllers/console/auth/login.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/api/controllers/console/auth/login.py b/api/controllers/console/auth/login.py index 6ae2291c3e..7b9cf25cc7 100644 --- a/api/controllers/console/auth/login.py +++ b/api/controllers/console/auth/login.py @@ -35,12 +35,14 @@ class LoginApi(Resource): try: account = AccountService.authenticate(args["email"], args["password"]) except services.errors.account.AccountLoginError as e: - if dify_config.ALLOW_REGISTER: - token = AccountService.send_reset_password_email(email=args["email"]) - return redirect(f"{dify_config.CONSOLE_WEB_URL}/reset-password?token={token}") - else: + return {"code": "unauthorized", "message": str(e)}, 401 + except services.errors.account.AccountNotFound as e: + if not dify_config.ALLOW_REGISTER: return {"code": "unauthorized", "message": str(e)}, 401 + token = AccountService.send_reset_password_email(email=args["email"]) + return redirect(f"{dify_config.CONSOLE_WEB_URL}/reset-password?token={token}") + # SELF_HOSTED only have one workspace tenants = TenantService.get_join_tenants(account) if len(tenants) == 0: