chore: apply pep8-naming rules for naming

This commit is contained in:
Joe 2024-09-12 11:47:36 +08:00
parent ce94a61f2f
commit dc04431d8a
3 changed files with 6 additions and 6 deletions

View File

@ -42,7 +42,7 @@ class LoginApi(Resource):
raise NotAllowedRegister() raise NotAllowedRegister()
except services.errors.account.AccountPasswordError: except services.errors.account.AccountPasswordError:
raise PasswordMismatchError() raise PasswordMismatchError()
except services.errors.account.AccountNotFound: except services.errors.account.AccountNotFoundError:
if not dify_config.ALLOW_REGISTER: if not dify_config.ALLOW_REGISTER:
raise NotAllowedRegister() raise NotAllowedRegister()

View File

@ -15,7 +15,7 @@ from libs.helper import get_remote_ip
from libs.oauth import GitHubOAuth, GoogleOAuth, OAuthUserInfo from libs.oauth import GitHubOAuth, GoogleOAuth, OAuthUserInfo
from models.account import Account, AccountStatus from models.account import Account, AccountStatus
from services.account_service import AccountService, RegisterService, TenantService 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 services.errors.workspace import WorkSpaceNotAllowedCreateError, WorkSpaceNotFoundError
from .. import api from .. import api
@ -90,7 +90,7 @@ class OAuthCallback(Resource):
try: try:
account = _generate_account(provider, user_info) account = _generate_account(provider, user_info)
except AccountNotFound: except AccountNotFoundError:
return redirect(f"{dify_config.CONSOLE_WEB_URL}/signin?message=AccountNotFound") return redirect(f"{dify_config.CONSOLE_WEB_URL}/signin?message=AccountNotFound")
except WorkSpaceNotFoundError: except WorkSpaceNotFoundError:
return redirect(f"{dify_config.CONSOLE_WEB_URL}/signin?message=WorkspaceNotFound") 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 account:
if not dify_config.ALLOW_REGISTER: if not dify_config.ALLOW_REGISTER:
raise AccountNotFound() raise AccountNotFoundError()
account_name = user_info.name if user_info.name else "Dify" account_name = user_info.name if user_info.name else "Dify"
account = RegisterService.register( account = RegisterService.register(
email=user_info.email, name=account_name, password=None, open_id=user_info.id, provider=provider email=user_info.email, name=account_name, password=None, open_id=user_info.id, provider=provider

View File

@ -23,7 +23,7 @@ from models.model import DifySetup
from services.errors.account import ( from services.errors.account import (
AccountAlreadyInTenantError, AccountAlreadyInTenantError,
AccountLoginError, AccountLoginError,
AccountNotFound, AccountNotFoundError,
AccountNotLinkTenantError, AccountNotLinkTenantError,
AccountPasswordError, AccountPasswordError,
AccountRegisterError, AccountRegisterError,
@ -95,7 +95,7 @@ class AccountService:
account = Account.query.filter_by(email=email).first() account = Account.query.filter_by(email=email).first()
if not account: if not account:
raise AccountNotFound() raise AccountNotFoundError()
if account.status == AccountStatus.BANNED.value or account.status == AccountStatus.CLOSED.value: if account.status == AccountStatus.BANNED.value or account.status == AccountStatus.CLOSED.value:
raise AccountLoginError("Account is banned or closed.") raise AccountLoginError("Account is banned or closed.")