feat: add NotAllowedCreateWorkspace and NotAllowedRegister

This commit is contained in:
Joe 2024-09-03 15:53:19 +08:00
parent d319913772
commit 78b1aabb67
2 changed files with 14 additions and 1 deletions

View File

@ -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"])

View File

@ -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