ng-idle
ng-idle copied to clipboard
Using JS Alert does not timeout until OK is Clicked
I am using ng-idle in my Angularjs 1.5.x . I am warning the user that his/her Session expires with a alert() box . When i do this the timeout does not trigger until the alert is responded to .
app.run(function ($rootScope, Idle) {
Idle.watch();
$rootScope.$on('IdleTimeout', function () {
// end their session and redirect to login.
console.log('Session expired');
globalThis._adalInstance.logOut();
});
$rootScope.$on('IdleStart', function () {
console.log('IDLE');
alert("Your session is about to expire. Please click anywhere on the page to avoid being logged out.");
});
});
I think that is a browser limitation, while the alert box is displayed the thread is held in suspension. This is why you shouldn't use alert boxes in modern UI javascript code.