mirror of
https://github.com/langgenius/dify.git
synced 2026-04-29 06:58:05 +08:00
feat: update raise error
This commit is contained in:
@ -49,3 +49,9 @@ class EmailPasswordLoginLimitError(BaseHTTPException):
|
||||
"Too many incorrect password attempts. Please verify your identity with the email code to complete login."
|
||||
)
|
||||
code = 429
|
||||
|
||||
|
||||
class EmailCodeLoginRateLimitExceededError(BaseHTTPException):
|
||||
error_code = "email_code_login_rate_limit_exceeded"
|
||||
description = "Too many login emails have been sent. Please try again in 5 minutes."
|
||||
code = 429
|
||||
|
||||
@ -43,14 +43,10 @@ class ForgotPasswordSendEmailApi(Resource):
|
||||
)
|
||||
else:
|
||||
raise NotAllowedRegister()
|
||||
elif account:
|
||||
try:
|
||||
token = AccountService.send_reset_password_email(
|
||||
account=account, email=args["email"], language=args["language"] or "en-US"
|
||||
)
|
||||
except RateLimitExceededError:
|
||||
logging.warning(f"Rate limit exceeded for email: {args['email']}")
|
||||
raise PasswordResetRateLimitExceededError()
|
||||
else:
|
||||
token = AccountService.send_reset_password_email(
|
||||
account=account, email=args["email"], language=args["language"] or "en-US"
|
||||
)
|
||||
|
||||
return {"result": "success", "data": token}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user