Skip to content

Commit

Permalink
don't act on token expiry broadcast if another login session is in pr…
Browse files Browse the repository at this point in the history
…ogress
  • Loading branch information
pliablepixels committed Oct 18, 2020
1 parent 7419d7d commit 0bfbc97
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion www/js/MontageCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ angular.module('zmApp.controllers')

apiurl += '.json?sort=StartTime&direction=desc&limit=1'+$rootScope.authSession;

NVR.debug ("Getting event count ");
//NVR.debug ("Getting event count ");
$http.get(apiurl)
.then (function (data) {
// console.log ("EVENTS GOT: "+JSON.stringify(data));
Expand Down
21 changes: 16 additions & 5 deletions www/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@ angular.module('zmApp', [
});

return out;
};

};
})

// filter for montage iteration
Expand Down Expand Up @@ -842,9 +842,13 @@ angular.module('zmApp', [
//------------------------------------------------------------------

$rootScope.$on("token-expiry", function () {
NVR.log ('-----> Access token is about to expire, re-doing login');
_doLogin("");

if ($rootScope.loginInProgress) {
NVR.log ('-----> got token expiry broadcast, but login in progress, not acting');
} else {
NVR.log ('-----> Access token is about to expire, re-doing login');
_doLogin("");
}

});

$rootScope.$on("auth-error", function () {
Expand Down Expand Up @@ -1001,10 +1005,14 @@ angular.module('zmApp', [


function _doLogin(str) {


var d = $q.defer();
$rootScope.loginInProgress = true;

if ($rootScope.userCancelledAuth) {
NVR.debug ('_doLogin - not proceeding as user cancelled auth');
$rootScope.loginInProgress = false;
d.reject(false);
return d.promise;
}
Expand Down Expand Up @@ -1040,6 +1048,7 @@ angular.module('zmApp', [
alertPopup.close();
}, 5000);

$rootScope.loginInProgress = false;
d.reject("Error-disable recaptcha");
return (d.promise);
}
Expand All @@ -1057,12 +1066,14 @@ angular.module('zmApp', [

//NVR.debug("Storing login time as " + moment().toString());
localforage.setItem("lastLogin", moment().toString());
$rootScope.loginInProgress = false;
d.resolve(success);
return d.promise;
},
function (error)
{
$ionicLoading.hide();
$rootScope.loginInProgress = false;
d.reject(error);
return d.promise;
});
Expand Down Expand Up @@ -1122,7 +1133,6 @@ angular.module('zmApp', [

//console.log(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>INSIDE RUN");

NVR.log("******* app .run device ready");
$fileLogger.setStorageFilename(zm.logFile);
$fileLogger.setTimestampFormat('MMM d, y ' + NVR.getTimeFormatMilliSec());

Expand All @@ -1138,6 +1148,7 @@ angular.module('zmApp', [
});


NVR.log("******* app .run device ready");

$rootScope.dpadId = 0;
$rootScope.textScaleFactor = 1.0;
Expand Down

0 comments on commit 0bfbc97

Please sign in to comment.