diff --git a/awx/ui/static/js/controllers/Authentication.js b/awx/ui/static/js/controllers/Authentication.js
index b39ada2527..70c3894889 100644
--- a/awx/ui/static/js/controllers/Authentication.js
+++ b/awx/ui/static/js/controllers/Authentication.js
@@ -14,13 +14,15 @@ function Authenticate($log, $cookieStore, $compile, $window, $scope, $rootScope,
Timer, Empty) {
var setLoginFocus, lastPath, sessionExpired,
- e, scope = $rootScope.$new();
+ e, html, scope = $rootScope.$new();
setLoginFocus = function () {
$('#login-username').focus();
};
- sessionExpired = (Empty($rootScope.sessionExpired)) ? $cookieStore.get('sessionExpired') : $rootScope.sessionExpired;
+ scope.sessionExpired = (Empty($rootScope.sessionExpired)) ? $cookieStore.get('sessionExpired') : $rootScope.sessionExpired;
+ scope.login_username = '';
+ scope.login_password = '';
lastPath = function () {
return (Empty($rootScope.lastPath)) ? $cookieStore.get('lastPath') : $rootScope.lastPath;
@@ -41,6 +43,50 @@ function Authenticate($log, $cookieStore, $compile, $window, $scope, $rootScope,
Wait('stop');
window.scrollTo(0,0);
+ if ($location.path() === '/logout') {
+ //if logout request, clear AuthToken and user session data
+ Authorization.logout();
+ }
+
+ e = angular.element(document.getElementById('login-modal-content'));
+ html = "
\n" +
+ "\n" +
+ "
Welcome to Ansible Tower! Please sign in.
\n" +
+ "
Your session timed out due to inactivity. Please sign in.
\n" +
+ "
\n" +
+ "
\n" +
+ "\n";
+ e.empty().html(html);
+ $compile(e)(scope);
+
+ // Set focus to username field
+ $('#login-modal').on('shown.bs.modal', function () {
+ setLoginFocus();
+ });
+
// Display the login dialog
$('#login-modal').modal({
show: true,
@@ -48,27 +94,11 @@ function Authenticate($log, $cookieStore, $compile, $window, $scope, $rootScope,
backdrop: 'static'
});
- // Set focus to username field
- $('#login-modal').on('shown.bs.modal', function () {
- setLoginFocus();
- });
-
- e = angular.element(document.getElementById('login-modal'));
- $compile(e)(scope);
-
// Reset the login form
- scope.login_username = null;
- scope.login_password = null;
- scope.loginForm.login_username.$setPristine();
- scope.loginForm.login_password.$setPristine();
-
- if ($location.path() === '/logout') {
- //if logout request, clear AuthToken and user session data
- Authorization.logout();
- }
-
- $rootScope.userLoggedIn = false; //hide the logout link. if you got here, you're logged out.
- $cookieStore.put('userLoggedIn', false); //gets set back to true by Authorization.setToken().
+ //scope.loginForm.login_username.$setPristine();
+ //scope.loginForm.login_password.$setPristine();
+ //$rootScope.userLoggedIn = false; //hide the logout link. if you got here, you're logged out.
+ //$cookieStore.put('userLoggedIn', false); //gets set back to true by Authorization.setToken().
$('#login-password').bind('keypress', function (e) {
var code = (e.keyCode ? e.keyCode : e.which);
diff --git a/awx/ui/static/lib/ansible/AuthService.js b/awx/ui/static/lib/ansible/AuthService.js
index b2522a0fac..d546f71369 100644
--- a/awx/ui/static/lib/ansible/AuthService.js
+++ b/awx/ui/static/lib/ansible/AuthService.js
@@ -59,13 +59,15 @@ angular.module('AuthService', ['ngCookies', 'Utilities'])
var scope = angular.element(document.getElementById('main-view')).scope();
scope.$destroy();
$rootScope.$destroy();
- $cookieStore.remove('token');
$cookieStore.remove('token_expires');
$cookieStore.remove('current_user');
$cookieStore.remove('lastPath');
+ $cookieStore.remove('lastPath', '/home');
+ $cookieStore.remove('token');
$cookieStore.put('userLoggedIn', false);
$cookieStore.put('sessionExpired', false);
- $cookieStore.remove('lastPath', '/home');
+ $cookieStore.put('token', '');
+ $cookieStore.put('current_user', {});
$rootScope.current_user = {};
$rootScope.license_tested = undefined;
$rootScope.userLoggedIn = false;
@@ -73,6 +75,8 @@ angular.module('AuthService', ['ngCookies', 'Utilities'])
$rootScope.token = null;
$rootScope.token_expires = null;
$rootScope.lastPath = '/home';
+ $rootScope.login_username = null;
+ $rootScope.login_password = null;
},
getLicense: function () {
diff --git a/awx/ui/static/lib/ansible/Utilities.js b/awx/ui/static/lib/ansible/Utilities.js
index 175d78f04c..72c11428b8 100644
--- a/awx/ui/static/lib/ansible/Utilities.js
+++ b/awx/ui/static/lib/ansible/Utilities.js
@@ -75,11 +75,10 @@ angular.module('Utilities', ['RestServices', 'Utilities'])
* alert-info...). Pass an optional function(){}, if you want a specific action to occur when user
* clicks 'OK' button. Set secondAlert to true, when a second dialog is needed.
*/
-.factory('Alert', ['$rootScope', '$compile', '$sce', function ($rootScope) {
+.factory('Alert', ['$rootScope', function ($rootScope) {
return function (hdr, msg, cls, action, secondAlert, disableButtons) {
- var scope = $rootScope.$new(), alertClass, e;
+ var scope = $rootScope.$new(), alertClass;
if (secondAlert) {
- e = angular.element(document.getElementById('alert-modal2'));
$('#alertHeader2').html(hdr);
$('#alert2-modal-msg').html(msg);
@@ -108,7 +107,6 @@ angular.module('Utilities', ['RestServices', 'Utilities'])
}
});
} else {
- e = angular.element(document.getElementById('alert-modal'));
$('#alertHeader').html(hdr);
$('#alert-modal-msg').html(msg);
diff --git a/awx/ui/templates/ui/index.html b/awx/ui/templates/ui/index.html
index 4bb8933ec8..29427c3125 100644
--- a/awx/ui/templates/ui/index.html
+++ b/awx/ui/templates/ui/index.html
@@ -263,38 +263,7 @@