diff options
| author | Pliable Pixels <pliablepixels@gmail.com> | 2019-07-08 11:36:37 -0400 |
|---|---|---|
| committer | Pliable Pixels <pliablepixels@gmail.com> | 2019-07-08 11:36:37 -0400 |
| commit | f683ea8023b71ab705ca37ea6ff60daa22c24a72 (patch) | |
| tree | 8a78a11dcb97fe0dbde3cc0d2d078a7194a3d368 /www/js/app.js | |
| parent | 6faf15bd652d0589e1fb30e559ad027525008e77 (diff) | |
#829 move to actual access token based timer
Diffstat (limited to 'www/js/app.js')
| -rwxr-xr-x | www/js/app.js | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/www/js/app.js b/www/js/app.js index 550d3de9..206f5e16 100755 --- a/www/js/app.js +++ b/www/js/app.js @@ -114,8 +114,8 @@ angular.module('zmApp', [ androidBackupKey: "AEdPqrEAAAAIqF-OaHdwIzZhx2L1WOfAGTagBxm5a1R4wBW_Uw", accessTokenLeewayMin: 5, refreshTokenLeewayMin: 10, - defaultAccessTokenExpiresMs: 30000 - //defaultAccessTokenExpiresMs: 1800000 // half of 3600s + // defaultAccessTokenExpiresMs: 30000 + // defaultAccessTokenExpiresMs: 1800000 // half of 3600s }) @@ -884,6 +884,12 @@ angular.module('zmApp', [ // doLogin() emits this when there is an auth error in the portal //------------------------------------------------------------------ + $rootScope.$on("token-expiry", function () { + NVR.log ('-----> Access token is about to expire, re-doing login'); + _doLogin(""); + + }); + $rootScope.$on("auth-error", function () { NVR.debug("zmAutoLogin: Inside auth-error broadcast"); @@ -1105,12 +1111,18 @@ angular.module('zmApp', [ //$rootScope.loggedIntoZm = 0; var timeInterval = ld.isTokenSupported ? zm.defaultAccessTokenExpiresMs: zm.loginInterval; $interval.cancel(zmAutoLoginHandle); - //doLogin(); - NVR.debug ('We will relogin every '+timeInterval/1000+' seconds, token supported='+ld.isTokenSupported) + + if (ld.isTokenSupported) { + NVR.debug ("------> Not starting login timer for token. We will start a one time timer when we know how soon the access token will live"); + _doLogin(""); + + } else { + NVR.debug ('We will relogin every '+timeInterval/1000+' seconds, token supported='+ld.isTokenSupported) zmAutoLoginHandle = $interval(function () { _doLogin(""); }, timeInterval); - + + } } |
