fix(domain-manager): prioritize non-seed workspaces in selection

Updated workspace selection logic to prioritize non-seed workspaces. Returns a seed workspace only if no non-seed workspaces are available to improve filtering consistency and avoid unintended behavior.
This commit is contained in:
Antoine Moreaux 2024-12-19 15:30:42 +01:00
parent 56daedb78f
commit 80b57cf957

View File

@ -145,7 +145,7 @@ export class DomainManagerService {
if (!this.environmentService.get('IS_MULTIWORKSPACE_ENABLED')) {
const workspaces = await this.workspaceRepository.find({
order: {
createdAt: 'DESC',
createdAt: 'ASC',
},
relations: ['workspaceSSOIdentityProviders'],
});
@ -164,7 +164,7 @@ export class DomainManagerService {
),
);
return nonSeedWorkspace ?? workspaces[workspaces.length - 1];
return nonSeedWorkspace ?? workspaces[0];
}
throw new Error(