diff --git a/awx/ui/client/src/controllers/Authentication.js b/awx/ui/client/src/controllers/Authentication.js index ccabce45aa..5b85c7c7e3 100644 --- a/awx/ui/client/src/controllers/Authentication.js +++ b/awx/ui/client/src/controllers/Authentication.js @@ -58,7 +58,7 @@ export function Authenticate($log, $cookieStore, $compile, $window, $rootScope, $location, Authorization, ToggleClass, Alert, Wait, Timer, Empty, ClearScope) { - var setLoginFocus, lastPath, sessionExpired, loginAgain, + var setLoginFocus, lastPath, lastUser, sessionExpired, loginAgain, e, html, scope = $rootScope.$new(); setLoginFocus = function () { @@ -83,6 +83,15 @@ export function Authenticate($log, $cookieStore, $compile, $window, $rootScope, return (Empty($rootScope.lastPath)) ? $cookieStore.get('lastPath') : $rootScope.lastPath; }; + lastUser = function(){ + if(!Empty($rootScope.lastUser) && $rootScope.lastUser === $rootScope.current_user.id){ + return true; + } + else { + return false; + } + }; + $log.debug('User session expired: ' + sessionExpired); $log.debug('Last URL: ' + lastPath()); @@ -176,7 +185,7 @@ export function Authenticate($log, $cookieStore, $compile, $window, $rootScope, .success(function (data) { Authorization.setLicense(data); Wait("stop"); - if (lastPath()) { + if (lastPath() && lastUser()) { // Go back to most recent navigation path $location.path(lastPath()); } else { diff --git a/awx/ui/client/src/shared/AuthService.js b/awx/ui/client/src/shared/AuthService.js index b83c22ae19..5224f7580b 100644 --- a/awx/ui/client/src/shared/AuthService.js +++ b/awx/ui/client/src/shared/AuthService.js @@ -67,8 +67,7 @@ angular.module('AuthService', ['ngCookies', Utilities.name]) var scope = angular.element(document.getElementById('main-view')).scope(); scope.$destroy(); //$rootScope.$destroy(); - $cookieStore.remove('token_expires'); - $cookieStore.remove('current_user'); + if($cookieStore.get('lastPath')==='/portal'){ $cookieStore.put( 'lastPath', '/portal'); @@ -76,7 +75,7 @@ angular.module('AuthService', ['ngCookies', Utilities.name]) } else if ($cookieStore.get('lastPath') !== '/home' || $cookieStore.get('lastPath') !== '/' || $cookieStore.get('lastPath') !== '/login' || $cookieStore.get('lastPath') !== '/logout'){ // do nothing - $rootScope.lastPath = $cookieStore.get('lastPath'); + $rootScope.lastPath = $cookieStore.get('lastPath'); } else { // your last path was home @@ -84,6 +83,9 @@ angular.module('AuthService', ['ngCookies', Utilities.name]) $rootScope.lastPath = '/home'; } + $rootScope.lastUser = $cookieStore.get('current_user').id; + $cookieStore.remove('token_expires'); + $cookieStore.remove('current_user'); $cookieStore.remove('token'); $cookieStore.put('userLoggedIn', false); $cookieStore.put('sessionExpired', false);