Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
fix: automatically create tenant for user (#793)
Matrifc7e4ac75bf0
diff --git a/api/app.py b/api/app.pyindex 591df943ebd..dac357c0e90 100644--- a/api/app.py+++ b/api/app.py@@ -31,6 +31,7 @@ from config import Config, CloudEditionConfigfrom commands import register_commandsfrom models.account import TenantAccountJoin, AccountStatusfrom models.model import Account, EndUser, App+from services.account_service import TenantServiceimport warningswarnings.simplefilter("ignore", ResourceWarning)@@ -89,6 +90,15 @@ def initialize_extensions(app):ext_sentry.init_app(app)+def _create_tenant_for_account(account):+ tenant = TenantService.create_tenant(f"{account.name}'s Workspace")++ TenantService.create_tenant_member(tenant, account, role='owner')+ account.current_tenant = tenant++ return tenant++# Flask-Login configuration@login_manager.user_loaderdef load_user(user_id):@@ -119,7 +129,9 @@ def load_user(user_id):if tenant_account_join:account.current_tenant_id = tenant_account_join.tenant_id- session['workspace_id'] = account.current_tenant_id+ else:+ _create_tenant_for_account(account)+ session['workspace_id'] = account.current_tenant_idelse:account.current_tenant_id = workspace_idelse:@@ -127,7 +139,9 @@ def load_user(user_id):TenantAccountJoin.account_id == account.id).first()if tenant_account_join:account.current_tenant_id = tenant_account_join.tenant_id- session['workspace_id'] = account.current_tenant_id+ else:+ _create_tenant_for_account(account)+ session['workspace_id'] = account.current_tenant_idaccount.last_active_at = datetime.utcnow()db.session.commit()diff --git a/api/controllers/console/auth/login.py b/api/controllers/console/auth/login.pyindex 89f5d917892..c78c54e411e 100644--- a/api/controllers/console/auth/login.py+++ b/api/controllers/console/auth/login.py@@ -35,7 +35,7 @@ class LoginApi(Resource):try:TenantService.switch_tenant(account)except Exception:- raise AccountNotLinkTenantError("Account not link tenant")+ passflask_login.login_user(account, remember=args['remember_me'])AccountService.update_last_login(account, request)