1
0
mirror of https://github.com/ansible/awx.git synced 2024-10-27 09:25:10 +03:00

Login dialog

If the attempt to get the license ('/api/v1/config') or user info ('/api/v1/me') fails, force user back to the login page. Additionally, call Authorization.logout() to make sure any residual token or user info is cleared.

Tweaked the login HTML so that ng-show on the login dialog header message will cause the message to show when the sessionExpired variable is null or undefined.
This commit is contained in:
Chris Houseknecht 2014-08-15 14:10:33 -04:00
parent d7d9c9f285
commit d869f82dc2
2 changed files with 15 additions and 13 deletions

View File

@ -13,13 +13,20 @@
function Authenticate($log, $cookieStore, $compile, $window, $scope, $rootScope, $location, Authorization, ToggleClass, Alert, Wait,
Timer, Empty) {
var setLoginFocus, lastPath, sessionExpired,
var setLoginFocus, lastPath, sessionExpired, loginAgain,
e, html, scope = $rootScope.$new();
setLoginFocus = function () {
$('#login-username').focus();
};
loginAgain = function() {
Authorization.logout();
setTimeout(function() {
window.location = '/#/logout'; // if we get here, force user back to re-login
}, 500);
};
scope.sessionExpired = (Empty($rootScope.sessionExpired)) ? $cookieStore.get('sessionExpired') : $rootScope.sessionExpired;
scope.login_username = '';
scope.login_password = '';
@ -53,8 +60,8 @@ function Authenticate($log, $cookieStore, $compile, $window, $scope, $rootScope,
"<img src=\"" + $basePath + "img/tower_console_logo.png\" />" +
"</div>\n" +
"<div class=\"modal-body\" id=\"login-modal-body\">\n" +
"<div class=\"login-alert\" ng-show=\"(sessionExpired == false)\">Welcome to Ansible Tower! &nbsp;Please sign in.</div>\n" +
"<div class=\"login-alert\" ng-show=\"(sessionExpired == true)\">Your session timed out due to inactivity. Please sign in.</div>\n" +
"<div class=\"login-alert\" ng-show=\"!sessionExpired\">Welcome to Ansible Tower! &nbsp;Please sign in.</div>\n" +
"<div class=\"login-alert\" ng-show=\"sessionExpired\">Your session timed out due to inactivity. Please sign in.</div>\n" +
"<form id=\"login-form\" name=\"loginForm\" class=\"form-horizontal\" autocomplete=\"off\" novalidate >\n" +
"<div class=\"form-group\">\n" +
"<label class=\"control-label col-md-offset-1 col-md-2 col-sm-offset-1 col-sm-2 col-xs-3 prepend-asterisk\">Username</label>\n" +
@ -129,7 +136,7 @@ function Authenticate($log, $cookieStore, $compile, $window, $scope, $rootScope,
})
.error(function () {
Wait('stop');
Alert('Error', 'Failed to access license information. GET returned status: ' + status, 'alert-danger', setLoginFocus);
Alert('Error', 'Failed to access license information. GET returned status: ' + status, 'alert-danger', loginAgain);
});
});
@ -146,7 +153,7 @@ function Authenticate($log, $cookieStore, $compile, $window, $scope, $rootScope,
})
.error(function (data, status) {
Wait('stop');
Alert('Error', 'Failed to access user information. GET returned status: ' + status, 'alert-danger', setLoginFocus);
Alert('Error', 'Failed to access user information. GET returned status: ' + status, 'alert-danger', loginAgain);
});
});

View File

@ -1,17 +1,12 @@
Alias /munin /var/cache/munin/www
<Directory /var/cache/munin/www>
Alias /munin /var/www/html/munin/
<Directory /var/www/html/munin/>
Order Allow,Deny
Allow from all
Options FollowSymLinks
AuthUserFile /var/lib/awx/.munin_htpasswd
AuthName "Munin"
AuthType Basic
require valid-user
<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault M310
</IfModule>
</Directory>
ScriptAlias /munin-cgi/munin-cgi-graph /var/www/cgi-bin/munin-cgi-graph