The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Fix/validate access token user not found (#8484)
Nicolas Rouannecde96cf52624
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 e924cd1675c..168e1c57461 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@@ -151,8 +151,13 @@ describe('JwtAuthStrategy', () => {);await expect(strategy.validate(payload as JwtPayload)).rejects.toThrow(- new AuthException('User not found', AuthExceptionCode.INVALID_INPUT),+ new AuthException('User not found', expect.any(String)),);+ try {+ await strategy.validate(payload as JwtPayload);+ } catch (e) {+ expect(e.code).toBe(AuthExceptionCode.USER_NOT_FOUND);+ }});it('should be truthy if type is ACCESS, no jti, and user exist', async () => {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 0ed9fa965d9..ae6c9906148 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@@ -113,7 +113,7 @@ export class JwtAuthStrategy extends PassportStrategy(Strategy, 'jwt') {if (!user) {throw new AuthException('User not found',- AuthExceptionCode.INVALID_INPUT,+ AuthExceptionCode.USER_NOT_FOUND,);}