diff --git a/packages/twenty-server/src/engine/core-modules/auth/token/services/access-token.service.ts b/packages/twenty-server/src/engine/core-modules/auth/token/services/access-token.service.ts index bb80d91af5..35e567d474 100644 --- a/packages/twenty-server/src/engine/core-modules/auth/token/services/access-token.service.ts +++ b/packages/twenty-server/src/engine/core-modules/auth/token/services/access-token.service.ts @@ -100,6 +100,7 @@ export class AccessTokenService { return { token: this.jwtWrapperService.sign(jwtPayload, { secret: this.jwtWrapperService.generateAppSecret('ACCESS', workspaceId), + expiresIn, }), expiresAt, }; diff --git a/packages/twenty-server/src/engine/core-modules/auth/token/services/refresh-token.service.ts b/packages/twenty-server/src/engine/core-modules/auth/token/services/refresh-token.service.ts index 7dfe5d68ec..ea574709bb 100644 --- a/packages/twenty-server/src/engine/core-modules/auth/token/services/refresh-token.service.ts +++ b/packages/twenty-server/src/engine/core-modules/auth/token/services/refresh-token.service.ts @@ -90,6 +90,14 @@ export class RefreshTokenService { ); } + // TODO: Delete this useless condition and error after March 31st 2025 + if (!token.workspaceId) { + throw new AuthException( + 'This refresh token is malformed', + AuthExceptionCode.INVALID_INPUT, + ); + } + return { user, token }; } @@ -115,10 +123,12 @@ export class RefreshTokenService { const refreshTokenPayload = { userId, expiresAt, + workspaceId, type: AppTokenType.RefreshToken, }; const jwtPayload = { sub: userId, + workspaceId, }; const refreshToken = this.appTokenRepository.create(refreshTokenPayload);