mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-12 08:38:58 +08:00
Feat/account not found (#10804)
This commit is contained in:
parent
3e2b8a8d02
commit
c49efc0c22
@ -12,7 +12,7 @@ from controllers.console.auth.error import (
|
|||||||
InvalidTokenError,
|
InvalidTokenError,
|
||||||
PasswordMismatchError,
|
PasswordMismatchError,
|
||||||
)
|
)
|
||||||
from controllers.console.error import EmailSendIpLimitError, NotAllowedRegister
|
from controllers.console.error import AccountNotFound, EmailSendIpLimitError
|
||||||
from controllers.console.wraps import setup_required
|
from controllers.console.wraps import setup_required
|
||||||
from events.tenant_event import tenant_was_created
|
from events.tenant_event import tenant_was_created
|
||||||
from extensions.ext_database import db
|
from extensions.ext_database import db
|
||||||
@ -48,7 +48,7 @@ class ForgotPasswordSendEmailApi(Resource):
|
|||||||
token = AccountService.send_reset_password_email(email=args["email"], language=language)
|
token = AccountService.send_reset_password_email(email=args["email"], language=language)
|
||||||
return {"result": "fail", "data": token, "code": "account_not_found"}
|
return {"result": "fail", "data": token, "code": "account_not_found"}
|
||||||
else:
|
else:
|
||||||
raise NotAllowedRegister()
|
raise AccountNotFound()
|
||||||
else:
|
else:
|
||||||
token = AccountService.send_reset_password_email(account=account, email=args["email"], language=language)
|
token = AccountService.send_reset_password_email(account=account, email=args["email"], language=language)
|
||||||
|
|
||||||
|
@ -16,9 +16,9 @@ from controllers.console.auth.error import (
|
|||||||
)
|
)
|
||||||
from controllers.console.error import (
|
from controllers.console.error import (
|
||||||
AccountBannedError,
|
AccountBannedError,
|
||||||
|
AccountNotFound,
|
||||||
EmailSendIpLimitError,
|
EmailSendIpLimitError,
|
||||||
NotAllowedCreateWorkspace,
|
NotAllowedCreateWorkspace,
|
||||||
NotAllowedRegister,
|
|
||||||
)
|
)
|
||||||
from controllers.console.wraps import setup_required
|
from controllers.console.wraps import setup_required
|
||||||
from events.tenant_event import tenant_was_created
|
from events.tenant_event import tenant_was_created
|
||||||
@ -76,7 +76,7 @@ class LoginApi(Resource):
|
|||||||
token = AccountService.send_reset_password_email(email=args["email"], language=language)
|
token = AccountService.send_reset_password_email(email=args["email"], language=language)
|
||||||
return {"result": "fail", "data": token, "code": "account_not_found"}
|
return {"result": "fail", "data": token, "code": "account_not_found"}
|
||||||
else:
|
else:
|
||||||
raise NotAllowedRegister()
|
raise AccountNotFound()
|
||||||
# SELF_HOSTED only have one workspace
|
# SELF_HOSTED only have one workspace
|
||||||
tenants = TenantService.get_join_tenants(account)
|
tenants = TenantService.get_join_tenants(account)
|
||||||
if len(tenants) == 0:
|
if len(tenants) == 0:
|
||||||
@ -119,7 +119,7 @@ class ResetPasswordSendEmailApi(Resource):
|
|||||||
if FeatureService.get_system_features().is_allow_register:
|
if FeatureService.get_system_features().is_allow_register:
|
||||||
token = AccountService.send_reset_password_email(email=args["email"], language=language)
|
token = AccountService.send_reset_password_email(email=args["email"], language=language)
|
||||||
else:
|
else:
|
||||||
raise NotAllowedRegister()
|
raise AccountNotFound()
|
||||||
else:
|
else:
|
||||||
token = AccountService.send_reset_password_email(account=account, language=language)
|
token = AccountService.send_reset_password_email(account=account, language=language)
|
||||||
|
|
||||||
@ -148,7 +148,7 @@ class EmailCodeLoginSendEmailApi(Resource):
|
|||||||
if FeatureService.get_system_features().is_allow_register:
|
if FeatureService.get_system_features().is_allow_register:
|
||||||
token = AccountService.send_email_code_login_email(email=args["email"], language=language)
|
token = AccountService.send_email_code_login_email(email=args["email"], language=language)
|
||||||
else:
|
else:
|
||||||
raise NotAllowedRegister()
|
raise AccountNotFound()
|
||||||
else:
|
else:
|
||||||
token = AccountService.send_email_code_login_email(account=account, language=language)
|
token = AccountService.send_email_code_login_email(account=account, language=language)
|
||||||
|
|
||||||
|
@ -52,8 +52,8 @@ class AccountBannedError(BaseHTTPException):
|
|||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
|
|
||||||
class NotAllowedRegister(BaseHTTPException):
|
class AccountNotFound(BaseHTTPException):
|
||||||
error_code = "unauthorized"
|
error_code = "account_not_found"
|
||||||
description = "Account not found."
|
description = "Account not found."
|
||||||
code = 400
|
code = 400
|
||||||
|
|
||||||
|
@ -198,9 +198,9 @@ class AccountService:
|
|||||||
) -> Account:
|
) -> Account:
|
||||||
"""create account"""
|
"""create account"""
|
||||||
if not FeatureService.get_system_features().is_allow_register and not is_setup:
|
if not FeatureService.get_system_features().is_allow_register and not is_setup:
|
||||||
from controllers.console.error import NotAllowedRegister
|
from controllers.console.error import AccountNotFound
|
||||||
|
|
||||||
raise NotAllowedRegister()
|
raise AccountNotFound()
|
||||||
account = Account()
|
account = Account()
|
||||||
account.email = email
|
account.email = email
|
||||||
account.name = name
|
account.name = name
|
||||||
|
Loading…
x
Reference in New Issue
Block a user