From f73e56439aedf7500a0a9aab7888653662395e61 Mon Sep 17 00:00:00 2001 From: Jared Tabor Date: Fri, 23 Oct 2015 17:08:44 -0700 Subject: [PATCH] On logout, log the user out of the UI on all open tabs I've also reworked the logic around storing the user session idle time in localStorage --- .../authentication.service.js | 8 ++++-- .../authenticationServices/timer.factory.js | 26 ++++++++++++++----- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/awx/ui/client/src/login/authenticationServices/authentication.service.js b/awx/ui/client/src/login/authenticationServices/authentication.service.js index 37426620a3..5ab9aced88 100644 --- a/awx/ui/client/src/login/authenticationServices/authentication.service.js +++ b/awx/ui/client/src/login/authenticationServices/authentication.service.js @@ -60,7 +60,8 @@ export default logout: function () { // the following puts our primary scope up for garbage collection, which // should prevent content flash from the prior user. - var scope = angular.element(document.getElementById('main-view')).scope(); + + var x, scope = angular.element(document.getElementById('main-view')).scope(); scope.$destroy(); //$rootScope.$destroy(); @@ -78,7 +79,10 @@ export default $cookieStore.remove('lastPath'); $rootScope.lastPath = '/home'; } - + x = Store('sessionTime'); + x[$rootScope.current_user.id].loggedIn = false; + Store('sessionTime', x); + $rootScope.lastUser = $cookieStore.get('current_user').id; $cookieStore.remove('token_expires'); $cookieStore.remove('current_user'); diff --git a/awx/ui/client/src/login/authenticationServices/timer.factory.js b/awx/ui/client/src/login/authenticationServices/timer.factory.js index 13ead3af02..d315ee50aa 100644 --- a/awx/ui/client/src/login/authenticationServices/timer.factory.js +++ b/awx/ui/client/src/login/authenticationServices/timer.factory.js @@ -32,13 +32,12 @@ export default timeout: null, getSessionTime: function () { - if(Store('sessionTime_'+$rootScope.current_user.id)){ - return Store('sessionTime_'+$rootScope.current_user.id); + if(Store('sessionTime')){ + return Store('sessionTime')[$rootScope.current_user.id].time; } else { - return 0; + return 0; } - }, isExpired: function (increase) { @@ -72,6 +71,7 @@ export default }, expireSession: function (reason) { + var x; if(reason === 'session_limit'){ $rootScope.sessionLimitExpired = true; $rootScope.sessionExpired = false; @@ -87,10 +87,21 @@ export default }, moveForward: function () { - var tm, t; + var tm, t, x, y; tm = ($AnsibleConfig.session_timeout) ? $AnsibleConfig.session_timeout : 1800; t = new Date().getTime() + (tm * 1000); - Store('sessionTime_'+$rootScope.current_user.id, t); + x = new Object({ + time: t, + loggedIn: true + }); + if(Store('sessionTime')){ + y = Store('sessionTime'); + } + else { + y = new Object(); + } + y[$rootScope.current_user.id] = x; + Store('sessionTime' , y); $rootScope.sessionExpired = false; $cookieStore.put('sessionExpired', false); this.startTimers(); @@ -149,6 +160,9 @@ export default } that.expireSession('idle'); } + if(Store('sessionTime')[$rootScope.current_user.id].loggedIn === false){ + that.expireSession(); + } }, 1000);