|
|
|
@ -49,7 +49,7 @@ from services.errors.account import (
|
|
|
|
RoleAlreadyAssignedError,
|
|
|
|
RoleAlreadyAssignedError,
|
|
|
|
TenantNotFoundError,
|
|
|
|
TenantNotFoundError,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
from services.errors.workspace import WorkSpaceNotAllowedCreateError
|
|
|
|
from services.errors.workspace import WorkSpaceNotAllowedCreateError, WorkspacesLimitExceededError
|
|
|
|
from services.feature_service import FeatureService
|
|
|
|
from services.feature_service import FeatureService
|
|
|
|
from tasks.delete_account_task import delete_account_task
|
|
|
|
from tasks.delete_account_task import delete_account_task
|
|
|
|
from tasks.mail_account_deletion_task import send_account_deletion_verification_code
|
|
|
|
from tasks.mail_account_deletion_task import send_account_deletion_verification_code
|
|
|
|
@ -410,11 +410,12 @@ class AccountService:
|
|
|
|
token = TokenManager.generate_token(
|
|
|
|
token = TokenManager.generate_token(
|
|
|
|
account=account, email=email, token_type="reset_password", additional_data={"code": code}
|
|
|
|
account=account, email=email, token_type="reset_password", additional_data={"code": code}
|
|
|
|
)
|
|
|
|
)
|
|
|
|
send_reset_password_mail_task.delay(
|
|
|
|
# send_reset_password_mail_task.delay(
|
|
|
|
language=language,
|
|
|
|
# language=language,
|
|
|
|
to=account_email,
|
|
|
|
# to=account_email,
|
|
|
|
code=code,
|
|
|
|
# code=code,
|
|
|
|
)
|
|
|
|
# )
|
|
|
|
|
|
|
|
print("code: ", code)
|
|
|
|
cls.reset_password_rate_limiter.increment_rate_limit(account_email)
|
|
|
|
cls.reset_password_rate_limiter.increment_rate_limit(account_email)
|
|
|
|
return token
|
|
|
|
return token
|
|
|
|
|
|
|
|
|
|
|
|
@ -442,11 +443,12 @@ class AccountService:
|
|
|
|
token = TokenManager.generate_token(
|
|
|
|
token = TokenManager.generate_token(
|
|
|
|
account=account, email=email, token_type="email_code_login", additional_data={"code": code}
|
|
|
|
account=account, email=email, token_type="email_code_login", additional_data={"code": code}
|
|
|
|
)
|
|
|
|
)
|
|
|
|
send_email_code_login_mail_task.delay(
|
|
|
|
# send_email_code_login_mail_task.delay(
|
|
|
|
language=language,
|
|
|
|
# language=language,
|
|
|
|
to=account.email if account else email,
|
|
|
|
# to=account.email if account else email,
|
|
|
|
code=code,
|
|
|
|
# code=code,
|
|
|
|
)
|
|
|
|
# )
|
|
|
|
|
|
|
|
print("code: ", code)
|
|
|
|
cls.email_code_login_rate_limiter.increment_rate_limit(email)
|
|
|
|
cls.email_code_login_rate_limiter.increment_rate_limit(email)
|
|
|
|
return token
|
|
|
|
return token
|
|
|
|
|
|
|
|
|
|
|
|
@ -588,9 +590,10 @@ class TenantService:
|
|
|
|
workspaces = FeatureService.get_system_features().license.workspaces
|
|
|
|
workspaces = FeatureService.get_system_features().license.workspaces
|
|
|
|
if (
|
|
|
|
if (
|
|
|
|
FeatureService.get_system_features().license.product_id == "DIFY_ENTERPRISE_STANDARD"
|
|
|
|
FeatureService.get_system_features().license.product_id == "DIFY_ENTERPRISE_STANDARD"
|
|
|
|
|
|
|
|
and workspaces.limit != 0 # if limit == 0, it means unlimited
|
|
|
|
and workspaces.limit - workspaces.size <= 0
|
|
|
|
and workspaces.limit - workspaces.size <= 0
|
|
|
|
):
|
|
|
|
):
|
|
|
|
raise WorkSpaceNotAllowedCreateError("workspace creation limit exceeded")
|
|
|
|
raise WorkspacesLimitExceededError()
|
|
|
|
|
|
|
|
|
|
|
|
if name:
|
|
|
|
if name:
|
|
|
|
tenant = TenantService.create_tenant(name=name, is_setup=is_setup)
|
|
|
|
tenant = TenantService.create_tenant(name=name, is_setup=is_setup)
|
|
|
|
|