feat: add NotAllowedCreateWorkspace and NotAllowedRegister

pull/8487/head
Joe 2 years ago
parent d319913772
commit 78b1aabb67

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

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

Loading…
Cancel
Save