mirror of
https://github.com/ansible/awx.git
synced 2026-03-07 11:41:08 -03:30
AC-301 organization data and related sets now cleared on logout.
This commit is contained in:
@@ -15,7 +15,7 @@ function Authenticate($window, $scope, $rootScope, $location, Authorization, Tog
|
|||||||
// Authorization is injected from AuthService found in services.js
|
// Authorization is injected from AuthService found in services.js
|
||||||
|
|
||||||
if ($location.path() == '/logout') {
|
if ($location.path() == '/logout') {
|
||||||
//if logout request, clear AuthToken and user session data
|
//if logout request, clear AuthToken and user session data
|
||||||
Authorization.logout();
|
Authorization.logout();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,11 +48,9 @@ function Authenticate($window, $scope, $rootScope, $location, Authorization, Tog
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Call the API to get an auth token
|
// Call the API to get an auth token
|
||||||
$scope.systemLogin = function(username, password) {
|
$scope.systemLogin = function(username, password) {
|
||||||
|
|
||||||
$('.api-error').empty();
|
$('.api-error').empty();
|
||||||
var token;
|
var token;
|
||||||
|
|
||||||
Authorization.retrieveToken(username, password)
|
Authorization.retrieveToken(username, password)
|
||||||
.success( function(data, status, headers, config) {
|
.success( function(data, status, headers, config) {
|
||||||
token = data.token;
|
token = data.token;
|
||||||
|
|||||||
@@ -5,8 +5,9 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
angular.module('AuthService', ['ngCookies'])
|
angular.module('AuthService', ['ngCookies', 'OrganizationFormDefinition'])
|
||||||
.factory('Authorization', ['$http', '$rootScope', '$location', '$cookieStore', function($http, $rootScope, $location, $cookieStore) {
|
.factory('Authorization', ['$http', '$rootScope', '$location', '$cookieStore', 'OrganizationForm',
|
||||||
|
function($http, $rootScope, $location, $cookieStore, OrganizationForm) {
|
||||||
return {
|
return {
|
||||||
setToken: function(token) {
|
setToken: function(token) {
|
||||||
// set the session cookie
|
// set the session cookie
|
||||||
@@ -67,23 +68,29 @@ angular.module('AuthService', ['ngCookies'])
|
|||||||
|
|
||||||
logout: function() {
|
logout: function() {
|
||||||
// the following puts our primary scope up for garbage collection, which
|
// 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();
|
var scope = angular.element(document.getElementById('main-view')).scope();
|
||||||
scope.$destroy();
|
scope.$destroy();
|
||||||
|
$rootScope.$destroy();
|
||||||
|
|
||||||
// but just in case, clear the organization bits
|
// Reset the scope for organizations. No matter what we have tried, nothing seems
|
||||||
$rootScope.organizations = null;
|
// to clear the scope fast enough to prevent prior user's content from displaying
|
||||||
|
$rootScope['organizations'] = null;
|
||||||
$rootScope.current_user = {};
|
for (var set in OrganizationForm.related) {
|
||||||
$rootScope.license_tested = undefined;
|
$rootScope[set] = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$cookieStore.remove('accordions');
|
||||||
$cookieStore.remove('token');
|
$cookieStore.remove('token');
|
||||||
$cookieStore.remove('token_expire');
|
$cookieStore.remove('token_expire');
|
||||||
$cookieStore.remove('current_user');
|
$cookieStore.remove('current_user');
|
||||||
|
$rootScope.current_user = {};
|
||||||
|
$rootScope.license_tested = undefined;
|
||||||
$rootScope.userLoggedIn = false;
|
$rootScope.userLoggedIn = false;
|
||||||
$rootScope.token = null;
|
$rootScope.token = null;
|
||||||
$rootScope.token_expire = new Date(1970, 0, 1, 0, 0, 0, 0);
|
$rootScope.token_expire = new Date(1970, 0, 1, 0, 0, 0, 0);
|
||||||
},
|
},
|
||||||
|
|
||||||
getLicense: function() {
|
getLicense: function() {
|
||||||
return $http({
|
return $http({
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
|
|||||||
@@ -133,7 +133,7 @@
|
|||||||
<li><a href="#jobs" data-toggle="tab">Jobs</a></li>
|
<li><a href="#jobs" data-toggle="tab">Jobs</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<div class="tab-content">
|
<div class="tab-content" ng-cloak>
|
||||||
<div ng-view id="main-view"></div>
|
<div ng-view id="main-view"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user