mirror of
https://github.com/langgenius/dify.git
synced 2024-11-16 19:59:50 +08:00
Merge: new-login into dev
This commit is contained in:
commit
fb46131a26
|
@ -27,7 +27,7 @@ class InvalidTokenError(BaseHTTPException):
|
||||||
|
|
||||||
class PasswordResetRateLimitExceededError(BaseHTTPException):
|
class PasswordResetRateLimitExceededError(BaseHTTPException):
|
||||||
error_code = "password_reset_rate_limit_exceeded"
|
error_code = "password_reset_rate_limit_exceeded"
|
||||||
description = "Too many password reset emails have been sent. Please try again in 5 minutes."
|
description = "Too many password reset emails have been sent. Please try again in 1 minutes."
|
||||||
code = 429
|
code = 429
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,7 @@ class LoginApi(Resource):
|
||||||
parser.add_argument("password", type=valid_password, required=True, location="json")
|
parser.add_argument("password", type=valid_password, required=True, location="json")
|
||||||
parser.add_argument("remember_me", type=bool, required=False, default=False, location="json")
|
parser.add_argument("remember_me", type=bool, required=False, default=False, location="json")
|
||||||
parser.add_argument("invite_token", type=str, required=False, default=None, location="json")
|
parser.add_argument("invite_token", type=str, required=False, default=None, location="json")
|
||||||
|
parser.add_argument("language", type=str, required=False, default="en-US", location="json")
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
is_login_error_rate_limit = AccountService.is_login_error_rate_limit(args["email"])
|
is_login_error_rate_limit = AccountService.is_login_error_rate_limit(args["email"])
|
||||||
|
@ -46,6 +47,11 @@ class LoginApi(Resource):
|
||||||
if invitation:
|
if invitation:
|
||||||
invitation = RegisterService.get_invitation_if_token_valid(None, args["email"], invitation)
|
invitation = RegisterService.get_invitation_if_token_valid(None, args["email"], invitation)
|
||||||
|
|
||||||
|
if args["language"] is not None and args["language"] == "zh-Hans":
|
||||||
|
language = "zh-Hans"
|
||||||
|
else:
|
||||||
|
language = "en-US"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if invitation:
|
if invitation:
|
||||||
data = invitation.get("data", {})
|
data = invitation.get("data", {})
|
||||||
|
@ -64,7 +70,7 @@ class LoginApi(Resource):
|
||||||
if not dify_config.ALLOW_REGISTER:
|
if not dify_config.ALLOW_REGISTER:
|
||||||
raise NotAllowedRegister()
|
raise NotAllowedRegister()
|
||||||
|
|
||||||
token = AccountService.send_reset_password_email(email=args["email"])
|
token = AccountService.send_reset_password_email(email=args["email"], language=language)
|
||||||
return {"result": "fail", "data": token, "message": "account_not_found"}
|
return {"result": "fail", "data": token, "message": "account_not_found"}
|
||||||
# SELF_HOSTED only have one workspace
|
# SELF_HOSTED only have one workspace
|
||||||
tenants = TenantService.get_join_tenants(account)
|
tenants = TenantService.get_join_tenants(account)
|
||||||
|
|
|
@ -340,7 +340,10 @@ class AccountService:
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def send_reset_password_email(
|
def send_reset_password_email(
|
||||||
cls, account: Optional[Account] = None, email: Optional[str] = None, language: Optional[str] = "en-US"
|
cls,
|
||||||
|
account: Optional[Account] = None,
|
||||||
|
email: Optional[str] = None,
|
||||||
|
language: Optional[str] = "en-US",
|
||||||
):
|
):
|
||||||
account_email = account.email if account else email
|
account_email = account.email if account else email
|
||||||
|
|
||||||
|
|
|
@ -133,4 +133,4 @@ class FeatureService:
|
||||||
features.sso_enforced_for_web = enterprise_info["sso_enforced_for_web"]
|
features.sso_enforced_for_web = enterprise_info["sso_enforced_for_web"]
|
||||||
features.sso_enforced_for_web_protocol = enterprise_info["sso_enforced_for_web_protocol"]
|
features.sso_enforced_for_web_protocol = enterprise_info["sso_enforced_for_web_protocol"]
|
||||||
features.enable_email_code_login = enterprise_info["enable_email_code_login"]
|
features.enable_email_code_login = enterprise_info["enable_email_code_login"]
|
||||||
features.enable_email_password_login = enterprise_info["enable_email_password_login"]
|
features.enable_email_password_login = enterprise_info["enable_email_password_login"]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user