mirror of
https://github.com/n8n-io/n8n.git
synced 2025-02-21 02:56:40 -08:00
fix(core): Fix browser session refreshes not working (#9212)
Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in>
This commit is contained in:
parent
306b68da6b
commit
1efeeccc5b
|
@ -150,7 +150,7 @@ export class AuthService {
|
|||
|
||||
if (jwtPayload.exp * 1000 - Date.now() < this.jwtRefreshTimeout) {
|
||||
this.logger.debug('JWT about to expire. Will be refreshed');
|
||||
this.issueCookie(res, user, jwtPayload.browserId);
|
||||
this.issueCookie(res, user, req.browserId);
|
||||
}
|
||||
|
||||
return user;
|
||||
|
|
|
@ -202,6 +202,13 @@ describe('AuthService', () => {
|
|||
sameSite: 'lax',
|
||||
secure: false,
|
||||
});
|
||||
|
||||
const newToken = res.cookie.mock.calls[0].at(1);
|
||||
expect(newToken).not.toBe(validToken);
|
||||
expect(await authService.resolveJwt(newToken, req, res)).toEqual(user);
|
||||
expect((jwt.decode(newToken) as jwt.JwtPayload).browserId).toEqual(
|
||||
(jwt.decode(validToken) as jwt.JwtPayload).browserId,
|
||||
);
|
||||
});
|
||||
|
||||
it('should refresh the cookie only if less than 1/4th of time is left', async () => {
|
||||
|
|
Loading…
Reference in a new issue