diff --git a/awx/ui/static/js/app.js b/awx/ui/static/js/app.js index 274fa2b64f..c636181275 100644 --- a/awx/ui/static/js/app.js +++ b/awx/ui/static/js/app.js @@ -270,12 +270,10 @@ angular.module('ansible', [ } // On each navigation request, check that the user is logged in - var tst = /(login|logout)/; - var path = $location.path(); - if ( !tst.test($location.path()) ) { + if ( !/^\/(login|logout)/.test($location.path()) ) { // capture most recent URL, excluding login/logout - $rootScope.lastPath = path; - $cookieStore.put('lastPath', path); + $rootScope.lastPath = $location.path(); + $cookieStore.put('lastPath', $location.path()); } if (Authorization.isUserLoggedIn() == false) { diff --git a/awx/ui/static/js/config.js b/awx/ui/static/js/config.js index b530850863..c7f6b47587 100644 --- a/awx/ui/static/js/config.js +++ b/awx/ui/static/js/config.js @@ -21,6 +21,6 @@ var $AnsibleConfig = // > password_strength = green // It also controls password validation. Passwords are rejected if the score is not > password_strength. - session_timeout: 1800 // Number of seconds before an inactive session is automatically timed out and forced to log in again. + session_timeout: 1800 // Number of seconds before an inactive session is automatically timed out and forced to log in again. // Separate from time out value set in API. } diff --git a/awx/ui/static/js/controllers/Authentication.js b/awx/ui/static/js/controllers/Authentication.js index ccc052dc18..ca102a4fbf 100644 --- a/awx/ui/static/js/controllers/Authentication.js +++ b/awx/ui/static/js/controllers/Authentication.js @@ -17,17 +17,15 @@ function Authenticate($cookieStore, $window, $scope, $rootScope, $location, Auth $('#login-username').focus(); }; - var sessionExpired = function() { - return (Empty($rootScope.sessionExpired)) ? $cookieStore.get('sessionExpired') : $rootScope.sessionExpired; - }(); + var sessionExpired = (Empty($rootScope.sessionExpired)) ? $cookieStore.get('sessionExpired') : $rootScope.sessionExpired; var lastPath = function() { return (Empty($rootScope.lastPath)) ? $cookieStore.get('lastPath') : $rootScope.lastPath; - }(); + } if ($AnsibleConfig.debug_mode && console) { console.log('User session expired: ' + sessionExpired); - console.log('Last URL: ' + lastPath); + console.log('Last URL: ' + lastPath()); } // Hide any lingering modal dialogs @@ -59,7 +57,6 @@ function Authenticate($cookieStore, $window, $scope, $rootScope, $location, Auth if ($location.path() == '/logout') { //if logout request, clear AuthToken and user session data Authorization.logout(); - $location.url('/home'); } $rootScope.userLoggedIn = false; //hide the logout link. if you got here, you're logged out. @@ -88,7 +85,6 @@ function Authenticate($cookieStore, $window, $scope, $rootScope, $location, Auth Wait('start'); Authorization.retrieveToken(username, password) .success( function(data, status, headers, config) { - Wait('stop'); $('#login-modal').modal('hide'); token = data.token; Authorization.setToken(data.token, data.expires); @@ -101,19 +97,21 @@ function Authenticate($cookieStore, $window, $scope, $rootScope, $location, Auth Authorization.getLicense() .success(function(data, status, headers, config) { Authorization.setLicense(data['license_info']); - if (lastPath) { + if (lastPath()) { // Go back to most recent navigation path - $location.path(lastPath); + $location.path(lastPath()); } else { $location.url('/home?login=true'); } }) .error(function(data, status, headers, config) { + Wait('stop'); Alert('Error', 'Failed to access user information. GET returned status: ' + status, 'alert-danger', setLoginFocus); }); }) .error( function(data, status, headers, config) { + Wait('stop'); Alert('Error', 'Failed to access license information. GET returned status: ' + status, 'alert-danger', setLoginFocus); }); }) diff --git a/awx/ui/static/lib/ansible/AuthService.js b/awx/ui/static/lib/ansible/AuthService.js index 8a417c8c69..f4c2672c15 100644 --- a/awx/ui/static/lib/ansible/AuthService.js +++ b/awx/ui/static/lib/ansible/AuthService.js @@ -56,13 +56,14 @@ angular.module('AuthService', ['ngCookies', 'Utilities']) $cookieStore.remove('lastPath'); $cookieStore.put('userLoggedIn', false); $cookieStore.put('sessionExpired', false); + $cookieStore.remove('lastPath', '/home'); $rootScope.current_user = {}; $rootScope.license_tested = undefined; $rootScope.userLoggedIn = false; $rootScope.sessionExpired = false; $rootScope.token = null; $rootScope.token_expires = null; - $rootScope.lastPath = '/'; + $rootScope.lastPath = '/home'; }, getLicense: function() {