The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
(fix) throw if Access JWT does not have a userWorkspaceId (#10225)
Marie68db9a7a8cb0
diff --git a/packages/twenty-server/src/engine/core-modules/auth/strategies/jwt.auth.strategy.spec.ts b/packages/twenty-server/src/engine/core-modules/auth/strategies/jwt.auth.strategy.spec.tsindex 192fbe17629..345b6d946ce 100644--- a/packages/twenty-server/src/engine/core-modules/auth/strategies/jwt.auth.strategy.spec.ts+++ b/packages/twenty-server/src/engine/core-modules/auth/strategies/jwt.auth.strategy.spec.ts@@ -208,10 +208,11 @@ describe('JwtAuthStrategy', () => {}});- it('should be truthy if type is ACCESS, no jti, and user and userWorkspace exist', async () => {+ it('should not throw if type is ACCESS, no jti, and user and userWorkspace exist', async () => {const payload = {sub: 'sub-default',type: 'ACCESS',+ userWorkspaceId: 'userWorkspaceId',};workspaceRepository = {diff --git a/packages/twenty-server/src/engine/core-modules/auth/strategies/jwt.auth.strategy.ts b/packages/twenty-server/src/engine/core-modules/auth/strategies/jwt.auth.strategy.tsindex d72cadb8820..780a43775d9 100644--- a/packages/twenty-server/src/engine/core-modules/auth/strategies/jwt.auth.strategy.ts+++ b/packages/twenty-server/src/engine/core-modules/auth/strategies/jwt.auth.strategy.ts@@ -120,6 +120,13 @@ export class JwtAuthStrategy extends PassportStrategy(Strategy, 'jwt') {);}+ if (!payload.userWorkspaceId) {+ throw new AuthException(+ 'UserWorkspace not found',+ AuthExceptionCode.USER_WORKSPACE_NOT_FOUND,+ );+ }+const userWorkspace = await this.userWorkspaceRepository.findOne({where: {id: payload.userWorkspaceId,