1
0
mirror of https://github.com/ansible/awx.git synced 2024-11-02 01:21:21 +03:00

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
This commit is contained in:
Jared Tabor 2015-10-23 17:08:44 -07:00
parent f8e4fdf201
commit f73e56439a
2 changed files with 26 additions and 8 deletions

View File

@ -60,7 +60,8 @@ export default
logout: function () { logout: function () {
// the following puts our primary scope up for garbage collection, which // the following puts our primary scope up for garbage collection, which
// should prevent content flash from the prior user. // 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(); scope.$destroy();
//$rootScope.$destroy(); //$rootScope.$destroy();
@ -78,6 +79,9 @@ export default
$cookieStore.remove('lastPath'); $cookieStore.remove('lastPath');
$rootScope.lastPath = '/home'; $rootScope.lastPath = '/home';
} }
x = Store('sessionTime');
x[$rootScope.current_user.id].loggedIn = false;
Store('sessionTime', x);
$rootScope.lastUser = $cookieStore.get('current_user').id; $rootScope.lastUser = $cookieStore.get('current_user').id;
$cookieStore.remove('token_expires'); $cookieStore.remove('token_expires');

View File

@ -32,13 +32,12 @@ export default
timeout: null, timeout: null,
getSessionTime: function () { getSessionTime: function () {
if(Store('sessionTime_'+$rootScope.current_user.id)){ if(Store('sessionTime')){
return Store('sessionTime_'+$rootScope.current_user.id); return Store('sessionTime')[$rootScope.current_user.id].time;
} }
else { else {
return 0; return 0;
} }
}, },
isExpired: function (increase) { isExpired: function (increase) {
@ -72,6 +71,7 @@ export default
}, },
expireSession: function (reason) { expireSession: function (reason) {
var x;
if(reason === 'session_limit'){ if(reason === 'session_limit'){
$rootScope.sessionLimitExpired = true; $rootScope.sessionLimitExpired = true;
$rootScope.sessionExpired = false; $rootScope.sessionExpired = false;
@ -87,10 +87,21 @@ export default
}, },
moveForward: function () { moveForward: function () {
var tm, t; var tm, t, x, y;
tm = ($AnsibleConfig.session_timeout) ? $AnsibleConfig.session_timeout : 1800; tm = ($AnsibleConfig.session_timeout) ? $AnsibleConfig.session_timeout : 1800;
t = new Date().getTime() + (tm * 1000); 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; $rootScope.sessionExpired = false;
$cookieStore.put('sessionExpired', false); $cookieStore.put('sessionExpired', false);
this.startTimers(); this.startTimers();
@ -149,6 +160,9 @@ export default
} }
that.expireSession('idle'); that.expireSession('idle');
} }
if(Store('sessionTime')[$rootScope.current_user.id].loggedIn === false){
that.expireSession();
}
}, 1000); }, 1000);