mirror of
https://github.com/ansible/awx.git
synced 2024-10-31 15:21:13 +03:00
AC-262, AC-260 fixed. Also fixed issue on Inventory where changing group name and/or description was not updating the Hosts view title on the right side of page.
This commit is contained in:
parent
c42c5624f6
commit
7fc08767f6
@ -10,7 +10,7 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
function Authenticate($scope, $rootScope, $location, Authorization, ToggleClass, Alert)
|
||||
function Authenticate($window, $scope, $rootScope, $location, Authorization, ToggleClass, Alert)
|
||||
{
|
||||
// Authorization is injected from AuthService found in services.js
|
||||
|
||||
@ -52,6 +52,14 @@ function Authenticate($scope, $rootScope, $location, Authorization, ToggleClass,
|
||||
Authorization.setToken(data.token);
|
||||
$scope.reset();
|
||||
|
||||
// Force request to /organizations to query with the correct token -in the event a new user
|
||||
// has logged in.
|
||||
var today = new Date();
|
||||
today.setTime(today.getTime() + ($AnsibleConfig.session_timeout * 1000));
|
||||
$rootScope.token = token;
|
||||
$rootScope.userLoggedIn = true;
|
||||
$rootScope.token_expire = today.getTime();
|
||||
|
||||
// Get all the profile/access info regarding the logged in user
|
||||
Authorization.getUser()
|
||||
.success(function(data, status, headers, config) {
|
||||
@ -94,5 +102,5 @@ function Authenticate($scope, $rootScope, $location, Authorization, ToggleClass,
|
||||
}
|
||||
}
|
||||
|
||||
Authenticate.$inject = ['$scope', '$rootScope', '$location', 'Authorization', 'ToggleClass', 'Alert'];
|
||||
Authenticate.$inject = ['$window', '$scope', '$rootScope', '$location', 'Authorization', 'ToggleClass', 'Alert'];
|
||||
|
||||
|
@ -142,8 +142,7 @@ function TeamsAdd ($scope, $rootScope, $compile, $location, $log, $routeParams,
|
||||
|
||||
TeamsAdd.$inject = [ '$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'TeamForm', 'GenerateForm',
|
||||
'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'ReturnToCaller', 'ClearScope', 'GenerateList',
|
||||
'OrganizationList', 'SearchInit', 'PaginateInit', 'TeamLookUpOrganizationInit', 'GetBasePath',
|
||||
'LookUpInit' ];
|
||||
'OrganizationList', 'SearchInit', 'PaginateInit', 'GetBasePath', 'LookUpInit' ];
|
||||
|
||||
|
||||
function TeamsEdit ($scope, $rootScope, $compile, $location, $log, $routeParams, TeamForm,
|
||||
|
@ -285,9 +285,12 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', '
|
||||
data[fld] = scope[fld];
|
||||
}
|
||||
data['inventory'] = inventory_id;
|
||||
|
||||
if (master['description'] != data['description']) {
|
||||
refreshHosts = true;
|
||||
|
||||
// Update hosts with new group name/description
|
||||
if (master['description'] != data['description'] ||
|
||||
master['name'] != data['name']) {
|
||||
scope.groupTitle = '<h4>' + data['name'] + '</h4>';
|
||||
scope.groupTitle += '<p>' + data['description'] + '</p>';
|
||||
}
|
||||
|
||||
Rest.setUrl(defaultUrl);
|
||||
|
@ -22,7 +22,7 @@ angular.module('RefreshHelper', ['RestServices', 'Utilities'])
|
||||
var set = params.set;
|
||||
var iterator = params.iterator;
|
||||
var url = params.url;
|
||||
|
||||
|
||||
Rest.setUrl(url);
|
||||
Rest.get()
|
||||
.success( function(data, status, headers, config) {
|
||||
|
@ -16,15 +16,18 @@ angular.module('AuthService', ['ngCookies'])
|
||||
$cookieStore.remove('token_expire');
|
||||
$cookieStore.put('token', token);
|
||||
$cookieStore.put('token_expire', today.getTime());
|
||||
$rootScope.token = token;
|
||||
$rootScope.userLoggedIn = true;
|
||||
$rootScope.token_expire = today.getTime();
|
||||
},
|
||||
|
||||
isTokenValid: function() {
|
||||
// check if token exists and is not expired
|
||||
var response = false;
|
||||
if ( $cookieStore.get('token') && $cookieStore.get('token_expire') ) {
|
||||
var token = $cookieStore.get('token');
|
||||
var exp = new Date($cookieStore.get('token_expire'));
|
||||
var token = ($rootScope.token) ? $rootScope.token : $cookieStore.get('token');
|
||||
var token_expire = ($rootScope.token_expire) ? $rootScope.token_expire : $cookieStore.get('token_expire');
|
||||
if (token && token_expire) {
|
||||
var exp = new Date(token_expire);
|
||||
var today = new Date();
|
||||
if (today < exp) {
|
||||
this.setToken(token); //push expiration into the future while user is active
|
||||
@ -37,8 +40,9 @@ angular.module('AuthService', ['ngCookies'])
|
||||
didSessionExpire: function() {
|
||||
// use only to test why user was sent to login page.
|
||||
var response = false;
|
||||
if ($cookieStore.get('token_expire')) {
|
||||
var exp = new Date($cookieStore.get('token_expire'));
|
||||
var token_expire = ($rootScope.token_expire) ? $rootScope.token_expire : $cookieStore.get('token_expire');
|
||||
if (token_expire) {
|
||||
var exp = new Date(token_expire);
|
||||
var today = new Date();
|
||||
if (exp < today) {
|
||||
response = true;
|
||||
@ -49,7 +53,7 @@ angular.module('AuthService', ['ngCookies'])
|
||||
|
||||
getToken: function() {
|
||||
if ( this.isTokenValid() ) {
|
||||
return $cookieStore.get('token');
|
||||
return ($rootScope.token) ? $rootScope.token : $cookieStore.get('token');
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
@ -68,6 +72,8 @@ angular.module('AuthService', ['ngCookies'])
|
||||
$cookieStore.remove('token_expire');
|
||||
$cookieStore.remove('current_user');
|
||||
$rootScope.userLoggedIn = false;
|
||||
$rootScope.token = null;
|
||||
$rootScope.token_expire = new Date(1970, 0, 1, 0, 0, 0, 0);
|
||||
},
|
||||
|
||||
getLicense: function() {
|
||||
|
@ -12,7 +12,11 @@ angular.module('RestServices',['ngCookies','AuthService'])
|
||||
this.url = url;
|
||||
},
|
||||
|
||||
auth: { 'Authorization': 'Token ' + Authorization.getToken() },
|
||||
//auth: { 'Authorization': 'Token ' + Authorization.getToken() },
|
||||
auth: function() {
|
||||
var token = Authorization.getToken();
|
||||
return { 'Authorization': 'Token ' + token }
|
||||
},
|
||||
|
||||
pReplace: function() {
|
||||
//in our url, replace :xx params with a value, assuming
|
||||
@ -33,20 +37,20 @@ angular.module('RestServices',['ngCookies','AuthService'])
|
||||
this.pReplace();
|
||||
return $http({method: 'GET',
|
||||
url: this.url,
|
||||
headers: this.auth,
|
||||
headers: this.auth(),
|
||||
params: this.params
|
||||
});
|
||||
},
|
||||
post: function(data) {
|
||||
return $http({method: 'POST',
|
||||
url: this.url,
|
||||
headers: this.auth,
|
||||
headers: this.auth(),
|
||||
data: data });
|
||||
},
|
||||
put: function(data) {
|
||||
return $http({method: 'PUT',
|
||||
url: this.url,
|
||||
headers: this.auth,
|
||||
headers: this.auth(),
|
||||
data: data });
|
||||
|
||||
},
|
||||
@ -54,7 +58,7 @@ angular.module('RestServices',['ngCookies','AuthService'])
|
||||
var url = this.url;
|
||||
return $http({method: 'DELETE',
|
||||
url: url,
|
||||
headers: this.auth,
|
||||
headers: this.auth(),
|
||||
data: data});
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ angular.module('Utilities',[])
|
||||
return function(id) {
|
||||
var element = document.getElementById(id);
|
||||
var scope = angular.element(element).scope();
|
||||
scope.$destroy();
|
||||
scope.$destroy();
|
||||
}
|
||||
})
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user