Skip to content

Commit 45a8f13

Browse files
razvanzthomseddon
authored andcommitted
fix: issue correct expiry dates for tokens (#2)
related to a NodeJS (nodejs/node#7074) and furthermore V8 bug (https://bugs.chromium.org/p/v8/issues/detail?id=3637); replaced seconds calculation with milliseconds.
1 parent 8be404f commit 45a8f13

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

lib/grant-types/abstract-grant-type.js

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,23 +67,15 @@ AbstractGrantType.prototype.generateRefreshToken = function(client, user, scope)
6767
*/
6868

6969
AbstractGrantType.prototype.getAccessTokenExpiresAt = function() {
70-
var expires = new Date();
71-
72-
expires.setSeconds(expires.getSeconds() + this.accessTokenLifetime);
73-
74-
return expires;
70+
return new Date(Date.now() + this.accessTokenLifetime * 1000);
7571
};
7672

7773
/**
7874
* Get refresh token expiration date.
7975
*/
8076

8177
AbstractGrantType.prototype.getRefreshTokenExpiresAt = function() {
82-
var expires = new Date();
83-
84-
expires.setSeconds(expires.getSeconds() + this.refreshTokenLifetime);
85-
86-
return expires;
78+
return new Date(Date.now() + this.refreshTokenLifetime * 1000);
8779
};
8880

8981
/**

0 commit comments

Comments
 (0)