|
@@ -116,7 +116,7 @@ class AccountService:
|
|
|
available_ta = (
|
|
|
# TenantAccountJoin.query.filter_by(account_id=account.id).order_by(TenantAccountJoin.id.asc()).first()
|
|
|
TenantAccountJoin.query.filter_by(account_id=account.id)
|
|
|
- .filter_by(role="owner")
|
|
|
+ #.filter_by(role="owner")
|
|
|
.order_by(TenantAccountJoin.id.asc())
|
|
|
.first()
|
|
|
)
|
|
@@ -225,7 +225,7 @@ class AccountService:
|
|
|
account = Account()
|
|
|
account.email = email
|
|
|
account.name = name
|
|
|
- password = email
|
|
|
+ password = "Szka&2@25"
|
|
|
if account.password is None:
|
|
|
# generate password salt
|
|
|
salt = secrets.token_bytes(16)
|
|
@@ -236,8 +236,8 @@ class AccountService:
|
|
|
|
|
|
account.password = base64_password_hashed
|
|
|
account.password_salt = base64_salt
|
|
|
- print("新注册账号密码:" + account.password)
|
|
|
- print("新注册账号密码:" + account.password_salt)
|
|
|
+ #print("新注册账号密码:" + account.password)
|
|
|
+ #print("新注册账号密码:" + account.password_salt)
|
|
|
account.interface_language = interface_language
|
|
|
account.interface_theme = interface_theme
|
|
|
|
|
@@ -662,7 +662,6 @@ class TenantService:
|
|
|
@staticmethod
|
|
|
def create_tenant_member(tenant: Tenant, account: Account, role: str = "normal") -> TenantAccountJoin:
|
|
|
"""Create tenant member"""
|
|
|
- print("打印4:")
|
|
|
if role == TenantAccountRole.OWNER.value:
|
|
|
if TenantService.has_roles(tenant, [TenantAccountRole.OWNER]):
|
|
|
logging.error(f"Tenant {tenant.id} has already an owner.")
|
|
@@ -709,7 +708,6 @@ class TenantService:
|
|
|
# Ensure tenant_id is provided
|
|
|
if tenant_id is None:
|
|
|
raise ValueError("Tenant ID must be provided.")
|
|
|
- print("打印4:")
|
|
|
tenant_account_join = (
|
|
|
db.session.query(TenantAccountJoin)
|
|
|
.join(Tenant, TenantAccountJoin.tenant_id == Tenant.id)
|
|
@@ -973,9 +971,7 @@ class RegisterService:
|
|
|
"""Invite new member"""
|
|
|
with Session(db.engine) as session:
|
|
|
account = session.query(Account).filter_by(email=email).first()
|
|
|
- print("打印2:")
|
|
|
if not account:
|
|
|
- print("打印3:")
|
|
|
TenantService.check_member_permission(tenant, inviter, None, "add")
|
|
|
name = email.split("@")[0]
|
|
|
|
|
@@ -986,21 +982,16 @@ class RegisterService:
|
|
|
TenantService.create_tenant_member(tenant, account, role)
|
|
|
TenantService.switch_tenant(account, tenant.id)
|
|
|
else:
|
|
|
- print("打印6:")
|
|
|
TenantService.check_member_permission(tenant, inviter, account, "add")
|
|
|
ta = TenantAccountJoin.query.filter_by(tenant_id=tenant.id, account_id=account.id).first()
|
|
|
|
|
|
if not ta:
|
|
|
- print("打印7:")
|
|
|
TenantService.create_tenant_member(tenant, account, role)
|
|
|
|
|
|
# Support resend invitation email when the account is pending status
|
|
|
if account.status != AccountStatus.PENDING.value:
|
|
|
- print("打印8:")
|
|
|
raise AccountAlreadyInTenantError("Account already in tenant.")
|
|
|
- print("打印9:")
|
|
|
token = cls.generate_invite_token(tenant, account)
|
|
|
- print("打印10:")
|
|
|
# send email
|
|
|
send_invite_member_mail_task.delay(
|
|
|
language=account.interface_language,
|
|
@@ -1009,7 +1000,6 @@ class RegisterService:
|
|
|
inviter_name=inviter.name if inviter else "Dify",
|
|
|
workspace_name=tenant.name,
|
|
|
)
|
|
|
- print("打印11:")
|
|
|
return token
|
|
|
|
|
|
@classmethod
|