From dc04431d8a7f22abfded0cc254a883938232f595 Mon Sep 17 00:00:00 2001 From: Joe <1264204425@qq.com> Date: Thu, 12 Sep 2024 11:47:36 +0800 Subject: [PATCH] chore: apply pep8-naming rules for naming --- api/controllers/console/auth/login.py | 2 +- api/controllers/console/auth/oauth.py | 6 +++--- api/services/account_service.py | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/api/controllers/console/auth/login.py b/api/controllers/console/auth/login.py index 1daaa44477..2a9e18912a 100644 --- a/api/controllers/console/auth/login.py +++ b/api/controllers/console/auth/login.py @@ -42,7 +42,7 @@ class LoginApi(Resource): raise NotAllowedRegister() except services.errors.account.AccountPasswordError: raise PasswordMismatchError() - except services.errors.account.AccountNotFound: + except services.errors.account.AccountNotFoundError: if not dify_config.ALLOW_REGISTER: raise NotAllowedRegister() diff --git a/api/controllers/console/auth/oauth.py b/api/controllers/console/auth/oauth.py index 0340c8c212..2dd050b30c 100644 --- a/api/controllers/console/auth/oauth.py +++ b/api/controllers/console/auth/oauth.py @@ -15,7 +15,7 @@ from libs.helper import get_remote_ip from libs.oauth import GitHubOAuth, GoogleOAuth, OAuthUserInfo from models.account import Account, AccountStatus from services.account_service import AccountService, RegisterService, TenantService -from services.errors.account import AccountNotFound +from services.errors.account import AccountNotFoundError from services.errors.workspace import WorkSpaceNotAllowedCreateError, WorkSpaceNotFoundError from .. import api @@ -90,7 +90,7 @@ class OAuthCallback(Resource): try: account = _generate_account(provider, user_info) - except AccountNotFound: + except AccountNotFoundError: return redirect(f"{dify_config.CONSOLE_WEB_URL}/signin?message=AccountNotFound") except WorkSpaceNotFoundError: return redirect(f"{dify_config.CONSOLE_WEB_URL}/signin?message=WorkspaceNotFound") @@ -148,7 +148,7 @@ def _generate_account(provider: str, user_info: OAuthUserInfo): if not account: if not dify_config.ALLOW_REGISTER: - raise AccountNotFound() + raise AccountNotFoundError() account_name = user_info.name if user_info.name else "Dify" account = RegisterService.register( email=user_info.email, name=account_name, password=None, open_id=user_info.id, provider=provider diff --git a/api/services/account_service.py b/api/services/account_service.py index db9e2ed1ad..c42b6d246a 100644 --- a/api/services/account_service.py +++ b/api/services/account_service.py @@ -23,7 +23,7 @@ from models.model import DifySetup from services.errors.account import ( AccountAlreadyInTenantError, AccountLoginError, - AccountNotFound, + AccountNotFoundError, AccountNotLinkTenantError, AccountPasswordError, AccountRegisterError, @@ -95,7 +95,7 @@ class AccountService: account = Account.query.filter_by(email=email).first() if not account: - raise AccountNotFound() + raise AccountNotFoundError() if account.status == AccountStatus.BANNED.value or account.status == AccountStatus.CLOSED.value: raise AccountLoginError("Account is banned or closed.")