diff --git a/awx/ui/client/src/login/authenticationServices/authentication.service.js b/awx/ui/client/src/login/authenticationServices/authentication.service.js index 8ffced6d09..d648bdd1eb 100644 --- a/awx/ui/client/src/login/authenticationServices/authentication.service.js +++ b/awx/ui/client/src/login/authenticationServices/authentication.service.js @@ -80,7 +80,9 @@ export default $rootScope.lastPath = '/home'; } x = Store('sessionTime'); - x[$rootScope.current_user.id].loggedIn = false; + if ($rootScope.current_user) { + x[$rootScope.current_user.id].loggedIn = false; + } Store('sessionTime', x); $rootScope.lastUser = $cookieStore.get('current_user').id; @@ -98,7 +100,9 @@ export default $rootScope.token_expires = null; $rootScope.login_username = null; $rootScope.login_password = null; - $rootScope.sessionTimer.clearTimers(); + if ($rootScope.sessionTimer) { + $rootScope.sessionTimer.clearTimers(); + } }, getLicense: function () { @@ -116,7 +120,7 @@ export default var license = data.license_info; license.analytics_status = data.analytics_status; license.version = data.version; - license.ansible_version = data.ansible_version; + license.ansible_version = data.ansible_version; license.tested = false; Store('license', license); $rootScope.features = Store('license').features; diff --git a/awx/ui/client/src/login/login.route.js b/awx/ui/client/src/login/login.route.js index 9f0bd8766b..cee67eebfe 100644 --- a/awx/ui/client/src/login/login.route.js +++ b/awx/ui/client/src/login/login.route.js @@ -9,5 +9,11 @@ import {templateUrl} from '../shared/template-url/template-url.factory'; export default { name: 'signIn', route: '/login', - templateUrl: templateUrl('login/loginBackDrop') + templateUrl: templateUrl('login/loginBackDrop'), + controller: ['$rootScope', 'Authorization', function($rootScope, Authorization) { + if (Authorization.isUserLoggedIn()) { + Authorization.logout(); + } + $(".LoginModal-dialog").remove(); + }] }; diff --git a/awx/ui/client/src/login/loginModal/loginModal.block.less b/awx/ui/client/src/login/loginModal/loginModal.block.less index 34f77bf899..4ab6d13187 100644 --- a/awx/ui/client/src/login/loginModal/loginModal.block.less +++ b/awx/ui/client/src/login/loginModal/loginModal.block.less @@ -1,4 +1,20 @@ /** @define LoginModal */ +.LoginModal-backDrop { + width: 100vw; + height: 100vh; + position: fixed; + top: 0; + left: 0; + z-index: 1041; + opacity: 0; + transition: 0.5s opacity; + background: #000; +} + +.LoginModal-backDrop.is-loggedOut { + opacity: 0.2; +} + .LoginModal-dialog { margin: 30px auto; margin-top: 135px; @@ -14,6 +30,8 @@ border-radius: 4px; opacity: 0; transition: opacity 0.5s; + z-index: 1042; + position: relative; } .LoginModal-content.is-loggedOut { diff --git a/awx/ui/client/src/login/loginModal/loginModal.controller.js b/awx/ui/client/src/login/loginModal/loginModal.controller.js index 9a2530b1f0..001abc3591 100644 --- a/awx/ui/client/src/login/loginModal/loginModal.controller.js +++ b/awx/ui/client/src/login/loginModal/loginModal.controller.js @@ -59,13 +59,7 @@ export default ['$log', '$cookieStore', '$compile', '$window', '$rootScope', '$l function ($log, $cookieStore, $compile, $window, $rootScope, $location, Authorization, ToggleClass, Alert, Wait, Timer, Empty, ClearScope, scope, pendoService) { - var setLoginFocus, lastPath, lastUser, sessionExpired, loginAgain; - - setLoginFocus = function () { - // Need to clear out any open dialog windows that might be open when this modal opens. - ClearScope(); - $('#login-username').focus(); - }; + var lastPath, lastUser, sessionExpired, loginAgain; loginAgain = function() { setTimeout(function() { @@ -93,27 +87,17 @@ export default ['$log', '$cookieStore', '$compile', '$window', '$rootScope', '$l $log.debug('User session expired: ' + sessionExpired); $log.debug('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 - // and scroll the window to the top - Wait('stop'); - window.scrollTo(0,0); - - // Set focus to username field - $('#login-modal').on('shown.bs.modal', function () { - setLoginFocus(); - }); - $rootScope.loginConfig.promise.then(function () { - scope.customLogo = ($AnsibleConfig.custom_logo) ? "custom_console_logo.png" : "tower_console_logo.png"; + if ($AnsibleConfig.custom_logo) { + scope.customLogo = "custom_console_logo.png"; + scope.customLogoPresent = true; + } else { + scope.customLogo = "login_modal_logo.png"; + scope.customLogoPresent = false; + } + scope.customLoginInfo = $AnsibleConfig.custom_login_info; - scope.customLoginInfoPresent = ($AnsibleConfig.customLoginInfo) ? true : false; + scope.customLoginInfoPresent = (scope.customLoginInfo) ? true : false; }); // Reset the login form @@ -122,19 +106,6 @@ export default ['$log', '$cookieStore', '$compile', '$window', '$rootScope', '$l //$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); - if (code === 13) { - $('#login-button').click(); - } - }); - - scope.reset = function () { - $('#login-form input').each(function () { - $(this).val(''); - }); - }; - if (scope.removeAuthorizationGetLicense) { scope.removeAuthorizationGetLicense(); } diff --git a/awx/ui/client/src/login/loginModal/loginModal.directive.js b/awx/ui/client/src/login/loginModal/loginModal.directive.js index 700399a4aa..058593eb4c 100644 --- a/awx/ui/client/src/login/loginModal/loginModal.directive.js +++ b/awx/ui/client/src/login/loginModal/loginModal.directive.js @@ -7,14 +7,53 @@ import authenticationController from './loginModal.controller'; /* jshint unused: vars */ export default - [ 'templateUrl', - function(templateUrl) { + [ 'templateUrl', + 'ClearScope', + 'Wait', + function(templateUrl, ClearScope, Wait) { return { restrict: 'E', scope: true, controller: authenticationController, templateUrl: templateUrl('login/loginModal/loginModal'), link: function(scope, element, attrs) { + var setLoginFocus = function () { + // Need to clear out any open dialog windows that might be open when this modal opens. + ClearScope(); + $('#login-username').focus(); + }; + + setLoginFocus(); + + // 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 + // and scroll the window to the top + Wait('stop'); + window.scrollTo(0,0); + + // Set focus to username field + $('#login-modal').on('shown.bs.modal', function () { + setLoginFocus(); + }); + + $('#login-password').bind('keypress', function (e) { + var code = (e.keyCode ? e.keyCode : e.which); + if (code === 13) { + $('#login-button').click(); + } + }); + + scope.reset = function () { + $('#login-form input').each(function () { + $(this).val(''); + }); + }; } }; } diff --git a/awx/ui/client/src/login/loginModal/loginModal.partial.html b/awx/ui/client/src/login/loginModal/loginModal.partial.html index fff09a430c..95603e01ce 100644 --- a/awx/ui/client/src/login/loginModal/loginModal.partial.html +++ b/awx/ui/client/src/login/loginModal/loginModal.partial.html @@ -1,4 +1,6 @@