diff --git a/awx/ui/client/src/app.js b/awx/ui/client/src/app.js index ab22556233..02b13f0f40 100644 --- a/awx/ui/client/src/app.js +++ b/awx/ui/client/src/app.js @@ -364,6 +364,9 @@ var tower = angular.module('Tower', [ if (!Authorization.getToken() || !Authorization.isUserLoggedIn()) { // User not authenticated, redirect to login page + if (!/^\/(login|logout)/.test($location.path())) { + $rootScope.preAuthUrl = $location.path(); + } $location.path('/login'); } else { var lastUser = $cookies.getObject('current_user'), diff --git a/awx/ui/client/src/login/loginModal/loginModal.controller.js b/awx/ui/client/src/login/loginModal/loginModal.controller.js index 470ab1fd50..e65728cb21 100644 --- a/awx/ui/client/src/login/loginModal/loginModal.controller.js +++ b/awx/ui/client/src/login/loginModal/loginModal.controller.js @@ -62,7 +62,7 @@ export default ['$log', '$cookies', '$compile', '$rootScope', Authorization, Alert, Wait, Timer, Empty, scope, pendoService, ConfigService, CheckLicense, FeaturesService, SocketService) { - var lastPath, lastUser, sessionExpired, loginAgain; + var lastPath, lastUser, sessionExpired, loginAgain, preAuthUrl; loginAgain = function() { setTimeout(function() { @@ -88,6 +88,8 @@ export default ['$log', '$cookies', '$compile', '$rootScope', } }; + preAuthUrl = $rootScope.preAuthUrl; + $log.debug('User session expired: ' + sessionExpired); $log.debug('Last URL: ' + lastPath()); @@ -112,11 +114,17 @@ export default ['$log', '$cookies', '$compile', '$rootScope', pendoService.issuePendoIdentity(); FeaturesService.get(); Wait("stop"); - if (lastPath() && lastUser()) { - // Go back to most recent navigation path - $location.path(lastPath()); - } else { - $location.url('/home'); + if(!Empty(preAuthUrl)){ + $location.path(preAuthUrl); + delete $rootScope.preAuthUrl; + } + else { + if (lastPath() && lastUser()) { + // Go back to most recent navigation path + $location.path(lastPath()); + } else { + $location.url('/home'); + } } }) .catch(function () {