diff --git a/api/controllers/console/auth/forgot_password.py b/api/controllers/console/auth/forgot_password.py index e3826b6ef6..2b12a77a2b 100644 --- a/api/controllers/console/auth/forgot_password.py +++ b/api/controllers/console/auth/forgot_password.py @@ -15,6 +15,7 @@ from controllers.console.auth.error import ( PasswordMismatchError, PasswordResetRateLimitExceededError, ) +from controllers.console.error import NotAllowedRegister from controllers.console.setup import setup_required from extensions.ext_database import db from libs.helper import email, get_remote_ip @@ -37,7 +38,7 @@ class ForgotPasswordSendEmailApi(Resource): if dify_config.ALLOW_REGISTER: token = AccountService.send_reset_password_email(email=args["email"]) else: - raise InvalidEmailError() + raise NotAllowedRegister() elif account: try: token = AccountService.send_reset_password_email(account=account, email=args["email"]) diff --git a/api/controllers/console/error.py b/api/controllers/console/error.py index 1c70ea6c59..3cc7bf9603 100644 --- a/api/controllers/console/error.py +++ b/api/controllers/console/error.py @@ -40,3 +40,15 @@ class AlreadyActivateError(BaseHTTPException): error_code = "already_activate" description = "Auth Token is invalid or account already activated, please check again." code = 403 + + +class NotAllowedCreateWorkspace(BaseHTTPException): + error_code = "unauthorized" + description = "Workspace not found, please contact system admin to invite you to join in a workspace." + code = 400 + + +class NotAllowedRegister(BaseHTTPException): + error_code = "unauthorized" + description = "Account not found." + code = 404