File tree Expand file tree Collapse file tree 1 file changed +7
-0
lines changed
packages/server/src/enterprise/services Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -104,13 +104,19 @@ export class AccountService {
104
104
}
105
105
}
106
106
107
+ private async ensureOneOrganizationOnly ( queryRunner : QueryRunner ) {
108
+ const organizations = await this . organizationservice . readOrganization ( queryRunner )
109
+ if ( organizations . length > 0 ) throw new InternalFlowiseError ( StatusCodes . BAD_REQUEST , 'You can only have one organization' )
110
+ }
111
+
107
112
private async createRegisterAccount ( data : AccountDTO , queryRunner : QueryRunner ) {
108
113
data = this . initializeAccountDTO ( data )
109
114
110
115
const platform = this . identityManager . getPlatformType ( )
111
116
112
117
switch ( platform ) {
113
118
case Platform . OPEN_SOURCE :
119
+ await this . ensureOneOrganizationOnly ( queryRunner )
114
120
data . organization . name = OrganizationName . DEFAULT_ORGANIZATION
115
121
data . organizationUser . role = await this . roleService . readGeneralRoleByName ( GeneralRole . OWNER , queryRunner )
116
122
data . workspace . name = WorkspaceName . DEFAULT_WORKSPACE
@@ -196,6 +202,7 @@ export class AccountService {
196
202
data . workspace . name = WorkspaceName . DEFAULT_PERSONAL_WORKSPACE
197
203
data . workspaceUser . role = await this . roleService . readGeneralRoleByName ( GeneralRole . PERSONAL_WORKSPACE , queryRunner )
198
204
} else {
205
+ await this . ensureOneOrganizationOnly ( queryRunner )
199
206
data . organizationUser . role = await this . roleService . readGeneralRoleByName ( GeneralRole . OWNER , queryRunner )
200
207
data . workspace . name = WorkspaceName . DEFAULT_WORKSPACE
201
208
data . workspaceUser . role = data . organizationUser . role
You can’t perform that action at this time.
0 commit comments