From a17f169e01fce82da678825007320e3983230e4f Mon Sep 17 00:00:00 2001 From: G81192 <41994631+G81192@users.noreply.github.com> Date: Fri, 25 Oct 2024 23:04:00 +0800 Subject: [PATCH] =?UTF-8?q?fix=20users=20had=20already=20joined=20a=20work?= =?UTF-8?q?space,=20but=20the=20system=20still=20first=20=E2=80=A6=20(#983?= =?UTF-8?q?4)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: yong.zhang --- api/services/account_service.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/api/services/account_service.py b/api/services/account_service.py index 412685147c..27b1540c8d 100644 --- a/api/services/account_service.py +++ b/api/services/account_service.py @@ -505,9 +505,7 @@ class TenantService: 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() ) @@ -515,6 +513,10 @@ class TenantService: 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: