From fa8a697024bec29a4289edc865afdeed69666ed4 Mon Sep 17 00:00:00 2001 From: chouseknecht Date: Tue, 30 Jul 2013 00:48:06 -0400 Subject: [PATCH] AC-301 organization data and related sets now cleared on logout. --- .../static/js/controllers/Authentication.js | 6 ++--- awx/ui/static/lib/ansible/authenticate.js | 25 ++++++++++++------- awx/ui/templates/ui/index.html | 2 +- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/awx/ui/static/js/controllers/Authentication.js b/awx/ui/static/js/controllers/Authentication.js index b1b4bcf025..d3fd4eb7cc 100644 --- a/awx/ui/static/js/controllers/Authentication.js +++ b/awx/ui/static/js/controllers/Authentication.js @@ -15,7 +15,7 @@ function Authenticate($window, $scope, $rootScope, $location, Authorization, Tog // Authorization is injected from AuthService found in services.js if ($location.path() == '/logout') { - //if logout request, clear AuthToken and user session data + //if logout request, clear AuthToken and user session data Authorization.logout(); } @@ -48,11 +48,9 @@ function Authenticate($window, $scope, $rootScope, $location, Authorization, Tog }; // Call the API to get an auth token - $scope.systemLogin = function(username, password) { - + $scope.systemLogin = function(username, password) { $('.api-error').empty(); var token; - Authorization.retrieveToken(username, password) .success( function(data, status, headers, config) { token = data.token; diff --git a/awx/ui/static/lib/ansible/authenticate.js b/awx/ui/static/lib/ansible/authenticate.js index ef92775da9..6b900db3e5 100644 --- a/awx/ui/static/lib/ansible/authenticate.js +++ b/awx/ui/static/lib/ansible/authenticate.js @@ -5,8 +5,9 @@ * */ -angular.module('AuthService', ['ngCookies']) - .factory('Authorization', ['$http', '$rootScope', '$location', '$cookieStore', function($http, $rootScope, $location, $cookieStore) { +angular.module('AuthService', ['ngCookies', 'OrganizationFormDefinition']) + .factory('Authorization', ['$http', '$rootScope', '$location', '$cookieStore', 'OrganizationForm', + function($http, $rootScope, $location, $cookieStore, OrganizationForm) { return { setToken: function(token) { // set the session cookie @@ -67,23 +68,29 @@ angular.module('AuthService', ['ngCookies']) logout: function() { // the following puts our primary scope up for garbage collection, which - // should prevent content flash from the prior user. + // should prevent content flash from the prior user. var scope = angular.element(document.getElementById('main-view')).scope(); scope.$destroy(); + $rootScope.$destroy(); - // but just in case, clear the organization bits - $rootScope.organizations = null; - - $rootScope.current_user = {}; - $rootScope.license_tested = undefined; + // Reset the scope for organizations. No matter what we have tried, nothing seems + // to clear the scope fast enough to prevent prior user's content from displaying + $rootScope['organizations'] = null; + for (var set in OrganizationForm.related) { + $rootScope[set] = null; + } + + $cookieStore.remove('accordions'); $cookieStore.remove('token'); $cookieStore.remove('token_expire'); $cookieStore.remove('current_user'); + $rootScope.current_user = {}; + $rootScope.license_tested = undefined; $rootScope.userLoggedIn = false; $rootScope.token = null; $rootScope.token_expire = new Date(1970, 0, 1, 0, 0, 0, 0); }, - + getLicense: function() { return $http({ method: 'GET', diff --git a/awx/ui/templates/ui/index.html b/awx/ui/templates/ui/index.html index 453c50a1bb..6746dec3ff 100644 --- a/awx/ui/templates/ui/index.html +++ b/awx/ui/templates/ui/index.html @@ -133,7 +133,7 @@
  • Jobs
  • -
    +