Skip to content

Commit

Permalink
fix users had already joined a workspace, but the system still first … (
Browse files Browse the repository at this point in the history
langgenius#9834)

Co-authored-by: yong.zhang <[email protected]>
  • Loading branch information
G81192 and G81192 authored Oct 25, 2024
1 parent 72ea3d6 commit a17f169
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions api/services/account_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -505,16 +505,18 @@ def create_tenant(name: str, is_setup: Optional[bool] = False) -> Tenant:
def create_owner_tenant_if_not_exist(
account: Account, name: Optional[str] = None, is_setup: Optional[bool] = False
):
"""Create owner tenant if not exist"""
if not FeatureService.get_system_features().is_allow_create_workspace and not is_setup:
raise WorkSpaceNotAllowedCreateError()
"""Check if user have a workspace or not"""
available_ta = (
TenantAccountJoin.query.filter_by(account_id=account.id).order_by(TenantAccountJoin.id.asc()).first()
)

if available_ta:
return

"""Create owner tenant if not exist"""
if not FeatureService.get_system_features().is_allow_create_workspace and not is_setup:
raise WorkSpaceNotAllowedCreateError()

if name:
tenant = TenantService.create_tenant(name=name, is_setup=is_setup)
else:
Expand Down

0 comments on commit a17f169

Please sign in to comment.