diff --git a/packages/twenty-server/src/engine/core-modules/jwt/services/jwt-wrapper.service.ts b/packages/twenty-server/src/engine/core-modules/jwt/services/jwt-wrapper.service.ts index d4b271c0d9..c3218efc08 100644 --- a/packages/twenty-server/src/engine/core-modules/jwt/services/jwt-wrapper.service.ts +++ b/packages/twenty-server/src/engine/core-modules/jwt/services/jwt-wrapper.service.ts @@ -137,7 +137,10 @@ export class JwtWrapperService { const payload = this.decode(token, { json: true }); if (!isDefined(payload)) { - throw new AuthException('No payload', AuthExceptionCode.UNAUTHENTICATED); + throw new AuthException( + 'Token invalid.', + AuthExceptionCode.UNAUTHENTICATED, + ); } const { key, algorithm } = await this.resolveVerificationKey(token); diff --git a/packages/twenty-server/test/integration/rest/suites/rest-api-core-authentication.integration-spec.ts b/packages/twenty-server/test/integration/rest/suites/rest-api-core-authentication.integration-spec.ts index ce4c8d3a59..926d4d8f46 100644 --- a/packages/twenty-server/test/integration/rest/suites/rest-api-core-authentication.integration-spec.ts +++ b/packages/twenty-server/test/integration/rest/suites/rest-api-core-authentication.integration-spec.ts @@ -27,7 +27,7 @@ describe('Core REST API Authentication', () => { }); }); - it('should return an Unauthenticated when no token is provided', async () => { + it('should return an Unauthenticated when a malformed token is provided', async () => { await makeRestAPIRequest({ method: 'post', path: `/people`, @@ -36,7 +36,7 @@ describe('Core REST API Authentication', () => { .expect(401) .expect((res) => { expect(res.body.error).toBe('UNAUTHENTICATED'); - expect(res.body.messages[0]).toBe('No payload'); + expect(res.body.messages[0]).toBe('Token invalid.'); }); });