check is email is freeze user email

pull/22900/head
Yansong Zhang 9 months ago
parent aca8b83669
commit 952bce4196

@ -113,3 +113,8 @@ class MemberNotInTenantError(BaseHTTPException):
error_code = "member_not_in_tenant"
description = "The member is not in the workspace."
code = 400
class AccountInFreezeError(BaseHTTPException):
error_code = "account_in_freeze"
description = "This email is temporarily unavailable."
code = 400

@ -14,6 +14,7 @@ from controllers.console.auth.error import (
EmailCodeError,
InvalidEmailError,
InvalidTokenError,
AccountInFreezeError
)
from controllers.console.error import AccountNotFound, EmailSendIpLimitError
from controllers.console.workspace.error import (
@ -488,6 +489,9 @@ class ChangeEmailResetApi(Resource):
if not AccountService.check_email_unique(args["new_email"]):
raise EmailAlreadyInUseError()
if AccountService.is_account_in_freeze(args["new_email"]):
raise AccountInFreezeError()
old_email = reset_data.get("old_email", "")
if current_user.email != old_email:
raise AccountNotFound()

@ -671,6 +671,12 @@ class AccountService:
return account
@classmethod
def is_account_in_freeze(cls, email: str) -> bool:
if dify_config.BILLING_ENABLED and BillingService.is_email_in_freeze(email):
return True
return False
@staticmethod
@redis_fallback(default_return=None)
def add_login_error_rate_limit(email: str) -> None:

Loading…
Cancel
Save