mirror of
https://github.com/ansible/awx.git
synced 2026-05-13 20:37:39 -02:30
AC-471 Added back client session timeout. Fixed Rest service library to bubble up expired session and invalid token errors via promise object, enabling correct error handling. Now tracking last URL in session cookie and returning user to last URL after successful login.
This commit is contained in:
@@ -10,12 +10,33 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
function Authenticate($cookieStore, $window, $scope, $rootScope, $location, Authorization, ToggleClass, Alert, Wait)
|
||||
function Authenticate($cookieStore, $window, $scope, $rootScope, $location, Authorization, ToggleClass, Alert, Wait,
|
||||
Timer, Empty)
|
||||
{
|
||||
var setLoginFocus = function() {
|
||||
$('#login-username').focus();
|
||||
};
|
||||
|
||||
var sessionExpired = function() {
|
||||
return (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);
|
||||
}
|
||||
|
||||
// Hide any lingering modal dialogs
|
||||
$('.modal[aria-hidden=false]').each( function() {
|
||||
if ($(this).attr('id') !== 'login-modal') {
|
||||
$(this).modal('hide');
|
||||
}
|
||||
});
|
||||
|
||||
// Just in case, make sure the wait widget is not active
|
||||
Wait('stop');
|
||||
|
||||
@@ -70,6 +91,7 @@ function Authenticate($cookieStore, $window, $scope, $rootScope, $location, Auth
|
||||
$('#login-modal').modal('hide');
|
||||
token = data.token;
|
||||
Authorization.setToken(data.token, data.expires);
|
||||
$rootScope.sessionTimer = Timer.init();
|
||||
// Get all the profile/access info regarding the logged in user
|
||||
Authorization.getUser()
|
||||
.success(function(data, status, headers, config) {
|
||||
@@ -77,7 +99,13 @@ function Authenticate($cookieStore, $window, $scope, $rootScope, $location, Auth
|
||||
Authorization.getLicense()
|
||||
.success(function(data, status, headers, config) {
|
||||
Authorization.setLicense(data['license_info']);
|
||||
$location.url('/home?login=true');
|
||||
if (lastPath) {
|
||||
// Go back to most recent navigation path
|
||||
$location.path(lastPath);
|
||||
}
|
||||
else {
|
||||
$location.url('/home?login=true');
|
||||
}
|
||||
})
|
||||
.error(function(data, status, headers, config) {
|
||||
Alert('Error', 'Failed to access user information. GET returned status: ' + status, 'alert-danger', setLoginFocus);
|
||||
@@ -113,5 +141,6 @@ function Authenticate($cookieStore, $window, $scope, $rootScope, $location, Auth
|
||||
}
|
||||
}
|
||||
|
||||
Authenticate.$inject = ['$cookieStore', '$window', '$scope', '$rootScope', '$location', 'Authorization', 'ToggleClass', 'Alert', 'Wait'];
|
||||
Authenticate.$inject = ['$cookieStore', '$window', '$scope', '$rootScope', '$location', 'Authorization', 'ToggleClass', 'Alert', 'Wait',
|
||||
'Timer', 'Empty'];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user