The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
fix(): avoid undefined workspaces with appToken when load availableWorkspaces (#12712)
Antoine Moreaux1bae411e5828
diff --git a/packages/twenty-front/src/modules/auth/components/Logo.tsx b/packages/twenty-front/src/modules/auth/components/Logo.tsxindex 24b2acab585..482be37acb7 100644--- a/packages/twenty-front/src/modules/auth/components/Logo.tsx+++ b/packages/twenty-front/src/modules/auth/components/Logo.tsx@@ -5,7 +5,7 @@ import { Avatar } from 'twenty-ui/display';import { UndecoratedLink } from 'twenty-ui/navigation';import { REACT_APP_SERVER_BASE_URL } from '~/config';import { useRedirectToDefaultDomain } from '~/modules/domain-manager/hooks/useRedirectToDefaultDomain';-import { useReadDefaultDomainFromConfiguration } from '@/domain-manager/hooks/useReadDefaultDomainFromConfiguration';+import { useReadDefaultDomainFromConfiguration } from '~/modules/domain-manager/hooks/useReadDefaultDomainFromConfiguration';type LogoProps = {primaryLogo?: string | null;diff --git a/packages/twenty-server/src/engine/core-modules/domain-manager/services/domain-manager.service.ts b/packages/twenty-server/src/engine/core-modules/domain-manager/services/domain-manager.service.tsindex f13fc186b99..870ef4fe62e 100644--- a/packages/twenty-server/src/engine/core-modules/domain-manager/services/domain-manager.service.ts+++ b/packages/twenty-server/src/engine/core-modules/domain-manager/services/domain-manager.service.ts@@ -112,14 +112,6 @@ export class DomainManagerService {};};- async getWorkspaceBySubdomainOrDefaultWorkspace(subdomain?: string) {- return subdomain- ? await this.workspaceRepository.findOne({- where: { subdomain },- })- : await this.getDefaultWorkspace();- }-isDefaultSubdomain(subdomain: string) {return subdomain === this.twentyConfigService.get('DEFAULT_SUBDOMAIN');}diff --git a/packages/twenty-server/src/engine/core-modules/user-workspace/user-workspace.service.ts b/packages/twenty-server/src/engine/core-modules/user-workspace/user-workspace.service.tsindex b93b80c6c68..052644093ff 100644--- a/packages/twenty-server/src/engine/core-modules/user-workspace/user-workspace.service.ts+++ b/packages/twenty-server/src/engine/core-modules/user-workspace/user-workspace.service.ts@@ -282,11 +282,11 @@ export class UserWorkspaceService extends TypeOrmQueryService<UserWorkspace> {await this.workspaceInvitationService.findInvitationsByEmail(email)).filter(- ({ workspaceId }) =>+ ({ workspace }) =>![...alreadyMemberWorkspacesIds,...workspacesFromApprovedAccessDomainIds,- ].includes(workspaceId),+ ].includes(workspace.id),).map((appToken) => ({workspace: appToken.workspace,diff --git a/packages/twenty-server/src/engine/core-modules/workspace-invitation/services/workspace-invitation.service.ts b/packages/twenty-server/src/engine/core-modules/workspace-invitation/services/workspace-invitation.service.tsindex e3318c907c0..d0c8f7c840f 100644--- a/packages/twenty-server/src/engine/core-modules/workspace-invitation/services/workspace-invitation.service.ts+++ b/packages/twenty-server/src/engine/core-modules/workspace-invitation/services/workspace-invitation.service.ts@@ -85,26 +85,10 @@ export class WorkspaceInvitationService {}}- async findInvitationByWorkspaceSubdomainAndUserEmail({- subdomain,- email,- }: {- subdomain: string;- email: string;- }) {- const workspace =- await this.domainManagerService.getWorkspaceBySubdomainOrDefaultWorkspace(- subdomain,- );-- if (!workspace) return;-- return await this.getOneWorkspaceInvitation(workspace.id, email);- }-async findInvitationsByEmail(email: string) {return await this.appTokenRepository.createQueryBuilder('appToken')+ .innerJoinAndSelect('appToken.workspace', 'workspace').where('"appToken".type = :type', {type: AppTokenType.InvitationToken,})@@ -113,7 +97,6 @@ export class WorkspaceInvitationService {.andWhere('appToken.expiresAt > :now', {now: new Date(),})- .leftJoinAndSelect('appToken.workspace', 'workspace').getMany();}