From c936aaa51753862914591b753f7f2d7be7749cf7 Mon Sep 17 00:00:00 2001 From: Shannon Date: Tue, 25 Mar 2014 11:45:38 +1100 Subject: [PATCH] Fixes: U4-3845 v7.0.0 keepUserLoggedIn issue --- .../src/common/services/user.service.js | 28 +++++++++++++------ 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/common/services/user.service.js b/src/Umbraco.Web.UI.Client/src/common/services/user.service.js index 3d1dec009d..95f4ba8ee2 100644 --- a/src/Umbraco.Web.UI.Client/src/common/services/user.service.js +++ b/src/Umbraco.Web.UI.Client/src/common/services/user.service.js @@ -61,7 +61,9 @@ angular.module('umbraco.services') there are no more seconds remaining. */ function countdownUserTimeout() { - $timeout(function() { + + $timeout(function () { + if (currentUser) { //countdown by 2 seconds since that is how long our timer is for. currentUser.remainingAuthSeconds -= 2; @@ -75,13 +77,19 @@ angular.module('umbraco.services') if (lastServerTimeoutSet != null) { var now = new Date(); var seconds = (now.getTime() - lastServerTimeoutSet.getTime()) / 1000; + if (seconds > 30) { + //first we'll set the lastServerTimeoutSet to null - this is so we don't get back in to this loop while we // wait for a response from the server otherwise we'll be making double/triple/etc... calls while we wait. lastServerTimeoutSet = null; + //now go get it from the server - authResource.getRemainingTimeoutSeconds().then(function(result) { - setUserTimeoutInternal(result); + //NOTE: the safeApply because our timeout is set to not run digests (performance reasons) + angularHelper.safeApply($rootScope, function() { + authResource.getRemainingTimeoutSeconds().then(function (result) { + setUserTimeoutInternal(result); + }); }); } } @@ -91,10 +99,10 @@ angular.module('umbraco.services') } else { - //we are either timed out or very close to timing out so we need to show the login dialog. - //NOTE: the safeApply because our timeout is set to not run digests (performance reasons) + //we are either timed out or very close to timing out so we need to show the login dialog. if (Umbraco.Sys.ServerVariables.umbracoSettings.keepUserLoggedIn !== true) { - angularHelper.safeApply($rootScope, function() { + //NOTE: the safeApply because our timeout is set to not run digests (performance reasons) + angularHelper.safeApply($rootScope, function () { userAuthExpired(); }); } @@ -105,9 +113,13 @@ angular.module('umbraco.services') //first we'll set the lastServerTimeoutSet to null - this is so we don't get back in to this loop while we // wait for a response from the server otherwise we'll be making double/triple/etc... calls while we wait. lastServerTimeoutSet = null; + //now go get it from the server - authResource.getRemainingTimeoutSeconds().then(function (result) { - setUserTimeoutInternal(result); + //NOTE: the safeApply because our timeout is set to not run digests (performance reasons) + angularHelper.safeApply($rootScope, function() { + authResource.getRemainingTimeoutSeconds().then(function (result) { + setUserTimeoutInternal(result); + }); }); }