Permalink
Browse files

fix(authService): limit setTimeout to it's maximum value of about ca …

…24.85d

fixes #375
  • Loading branch information...
doktordirk committed Apr 23, 2018
1 parent 6d0f681 commit 3c51df67bfe4447d0f6eeea7f0a45ef6288f7a21
Showing with 10 additions and 0 deletions.
  1. +2 −0 doc/api_authService.md
  2. +8 −0 src/authService.js
@@ -95,6 +95,8 @@ Sets the login timeout.
CAUTION: .authenticated and isAuthenticated() might get different results when set manually.
WARNING: Maximum timeout is 2^31 - 1 ms (ca. 24.85d).
#### Parameters
| Parameter | Type | Description |
@@ -148,6 +148,14 @@ export class AuthService {
* @param {number} ttl Timeout time in ms
*/
setTimeout(ttl: number) {
const maxTimeout = 2147483647; // maximum period in ms (ca. 24.85d) for windows.setTimeout
// limit timer ttl to max value allowed for windows.setTimeout function
if (ttl > maxTimeout) {
ttl = maxTimeout;
logger.warn('Token timeout limited to ', maxTimeout, ' ms (ca 24.85d).');
}
this.clearTimeout();
const expiredTokenHandler = () => {

0 comments on commit 3c51df6

Please sign in to comment.