diff --git a/awx/ui/static/js/app.js b/awx/ui/static/js/app.js index e97ecfd9cc..80377297a0 100644 --- a/awx/ui/static/js/app.js +++ b/awx/ui/static/js/app.js @@ -180,7 +180,6 @@ var tower = angular.module('Tower', [ .constant('$timezones.definitions.location', urlPrefix + 'lib/angular-tz-extensions/tz/data') .config(['$routeProvider', function ($routeProvider) { - $routeProvider. when('/jobs', { @@ -644,6 +643,7 @@ var tower = angular.module('Tower', [ if (!/^\/(login|logout)/.test($location.path())) { // capture most recent URL, excluding login/logout $rootScope.lastPath = $location.path(); + $rootScope.enteredPath = $location.path(); $cookieStore.put('lastPath', $location.path()); } diff --git a/awx/ui/static/js/controllers/Authentication.js b/awx/ui/static/js/controllers/Authentication.js index 0cc90d57c7..922220b46b 100644 --- a/awx/ui/static/js/controllers/Authentication.js +++ b/awx/ui/static/js/controllers/Authentication.js @@ -105,6 +105,16 @@ export function Authenticate($log, $cookieStore, $compile, $window, $rootScope, if ($location.path() === '/logout') { //if logout request, clear AuthToken and user session data Authorization.logout(); + } else if ($location.path() === '/login') { + if ($rootScope.enteredPath) { + $rootScope.lastPath = $rootScope.enteredPath; + } else if (!$rootScope.lastPath) { + // your last path was home + $cookieStore.remove('lastPath'); + $rootScope.lastPath = '/home'; + } + } else { + $rootScope.enteredPath = $location.path(); } e = angular.element(document.getElementById('login-modal-content')); diff --git a/awx/ui/static/js/helpers/LoadConfig.js b/awx/ui/static/js/helpers/LoadConfig.js index 90bf5428bb..668192b04b 100644 --- a/awx/ui/static/js/helpers/LoadConfig.js +++ b/awx/ui/static/js/helpers/LoadConfig.js @@ -19,7 +19,7 @@ export default angular.module('LoadConfigHelper', ['Utilities']) -.factory('LoadConfig', ['$log', '$rootScope', '$http', 'ProcessErrors', 'Store', function($log, $rootScope, $http, ProcessErrors, Store) { +.factory('LoadConfig', ['$log', '$rootScope', '$http', '$location', 'ProcessErrors', 'Store', function($log, $rootScope, $http, $location, ProcessErrors, Store) { return function() { if ($rootScope.removeLoadConfig) { @@ -42,6 +42,7 @@ angular.module('LoadConfigHelper', ['Utilities']) }); }); + $rootScope.enteredPath = $location.path(); // Load js/local_config.js $http({ method:'GET', url: $basePath + 'js/local_config.js' }) .success(function(data) { diff --git a/awx/ui/static/js/shared/AuthService.js b/awx/ui/static/js/shared/AuthService.js index 717122a01c..aab7f41aea 100644 --- a/awx/ui/static/js/shared/AuthService.js +++ b/awx/ui/static/js/shared/AuthService.js @@ -70,7 +70,12 @@ angular.module('AuthService', ['ngCookies', Utilities.name]) $cookieStore.put( 'lastPath', '/portal'); $rootScope.lastPath = '/portal'; } + else if ($cookieStore.get('lastPath') !== '/home' || $cookieStore.get('lastPath') !== '/'){ + // do nothing + $rootScope.lastPath = $cookieStore.get('lastPath'); + } else { + // your last path was home $cookieStore.remove('lastPath'); $rootScope.lastPath = '/home'; }