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, function Authenticate($log, $cookieStore, $compile, $window, $scope, $rootScope, $location, Authorization, ToggleClass, Alert, Wait,
Timer, Empty) { Timer, Empty) {
var setLoginFocus, lastPath, sessionExpired, var setLoginFocus, lastPath, sessionExpired, loginAgain,
e, html, scope = $rootScope.$new(); e, html, scope = $rootScope.$new();
setLoginFocus = function () { setLoginFocus = function () {
$('#login-username').focus(); $('#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.sessionExpired = (Empty($rootScope.sessionExpired)) ? $cookieStore.get('sessionExpired') : $rootScope.sessionExpired;
scope.login_username = ''; scope.login_username = '';
scope.login_password = ''; scope.login_password = '';
@@ -53,8 +60,8 @@ function Authenticate($log, $cookieStore, $compile, $window, $scope, $rootScope,
"<img src=\"" + $basePath + "img/tower_console_logo.png\" />" + "<img src=\"" + $basePath + "img/tower_console_logo.png\" />" +
"</div>\n" + "</div>\n" +
"<div class=\"modal-body\" id=\"login-modal-body\">\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\">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\">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" + "<form id=\"login-form\" name=\"loginForm\" class=\"form-horizontal\" autocomplete=\"off\" novalidate >\n" +
"<div class=\"form-group\">\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" + "<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 () { .error(function () {
Wait('stop'); 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) { .error(function (data, status) {
Wait('stop'); 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/www/html/munin/
Alias /munin /var/cache/munin/www <Directory /var/www/html/munin/>
<Directory /var/cache/munin/www>
Order Allow,Deny Order Allow,Deny
Allow from all Allow from all
Options FollowSymLinks
AuthUserFile /var/lib/awx/.munin_htpasswd AuthUserFile /var/lib/awx/.munin_htpasswd
AuthName "Munin" AuthName "Munin"
AuthType Basic AuthType Basic
require valid-user require valid-user
<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault M310
</IfModule>
</Directory> </Directory>
ScriptAlias /munin-cgi/munin-cgi-graph /var/www/cgi-bin/munin-cgi-graph