mirror of
https://github.com/ansible/awx.git
synced 2026-03-26 05:15:02 -02:30
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:
@@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
'use strict';
|
'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
|
// Authorization is injected from AuthService found in services.js
|
||||||
|
|
||||||
@@ -52,6 +52,14 @@ function Authenticate($scope, $rootScope, $location, Authorization, ToggleClass,
|
|||||||
Authorization.setToken(data.token);
|
Authorization.setToken(data.token);
|
||||||
$scope.reset();
|
$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
|
// Get all the profile/access info regarding the logged in user
|
||||||
Authorization.getUser()
|
Authorization.getUser()
|
||||||
.success(function(data, status, headers, config) {
|
.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',
|
TeamsAdd.$inject = [ '$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'TeamForm', 'GenerateForm',
|
||||||
'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'ReturnToCaller', 'ClearScope', 'GenerateList',
|
'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'ReturnToCaller', 'ClearScope', 'GenerateList',
|
||||||
'OrganizationList', 'SearchInit', 'PaginateInit', 'TeamLookUpOrganizationInit', 'GetBasePath',
|
'OrganizationList', 'SearchInit', 'PaginateInit', 'GetBasePath', 'LookUpInit' ];
|
||||||
'LookUpInit' ];
|
|
||||||
|
|
||||||
|
|
||||||
function TeamsEdit ($scope, $rootScope, $compile, $location, $log, $routeParams, TeamForm,
|
function TeamsEdit ($scope, $rootScope, $compile, $location, $log, $routeParams, TeamForm,
|
||||||
|
|||||||
@@ -285,9 +285,12 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', '
|
|||||||
data[fld] = scope[fld];
|
data[fld] = scope[fld];
|
||||||
}
|
}
|
||||||
data['inventory'] = inventory_id;
|
data['inventory'] = inventory_id;
|
||||||
|
|
||||||
if (master['description'] != data['description']) {
|
// Update hosts with new group name/description
|
||||||
refreshHosts = true;
|
if (master['description'] != data['description'] ||
|
||||||
|
master['name'] != data['name']) {
|
||||||
|
scope.groupTitle = '<h4>' + data['name'] + '</h4>';
|
||||||
|
scope.groupTitle += '<p>' + data['description'] + '</p>';
|
||||||
}
|
}
|
||||||
|
|
||||||
Rest.setUrl(defaultUrl);
|
Rest.setUrl(defaultUrl);
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ angular.module('RefreshHelper', ['RestServices', 'Utilities'])
|
|||||||
var set = params.set;
|
var set = params.set;
|
||||||
var iterator = params.iterator;
|
var iterator = params.iterator;
|
||||||
var url = params.url;
|
var url = params.url;
|
||||||
|
|
||||||
Rest.setUrl(url);
|
Rest.setUrl(url);
|
||||||
Rest.get()
|
Rest.get()
|
||||||
.success( function(data, status, headers, config) {
|
.success( function(data, status, headers, config) {
|
||||||
|
|||||||
@@ -16,15 +16,18 @@ angular.module('AuthService', ['ngCookies'])
|
|||||||
$cookieStore.remove('token_expire');
|
$cookieStore.remove('token_expire');
|
||||||
$cookieStore.put('token', token);
|
$cookieStore.put('token', token);
|
||||||
$cookieStore.put('token_expire', today.getTime());
|
$cookieStore.put('token_expire', today.getTime());
|
||||||
|
$rootScope.token = token;
|
||||||
$rootScope.userLoggedIn = true;
|
$rootScope.userLoggedIn = true;
|
||||||
|
$rootScope.token_expire = today.getTime();
|
||||||
},
|
},
|
||||||
|
|
||||||
isTokenValid: function() {
|
isTokenValid: function() {
|
||||||
// check if token exists and is not expired
|
// check if token exists and is not expired
|
||||||
var response = false;
|
var response = false;
|
||||||
if ( $cookieStore.get('token') && $cookieStore.get('token_expire') ) {
|
var token = ($rootScope.token) ? $rootScope.token : $cookieStore.get('token');
|
||||||
var token = $cookieStore.get('token');
|
var token_expire = ($rootScope.token_expire) ? $rootScope.token_expire : $cookieStore.get('token_expire');
|
||||||
var exp = new Date($cookieStore.get('token_expire'));
|
if (token && token_expire) {
|
||||||
|
var exp = new Date(token_expire);
|
||||||
var today = new Date();
|
var today = new Date();
|
||||||
if (today < exp) {
|
if (today < exp) {
|
||||||
this.setToken(token); //push expiration into the future while user is active
|
this.setToken(token); //push expiration into the future while user is active
|
||||||
@@ -37,8 +40,9 @@ angular.module('AuthService', ['ngCookies'])
|
|||||||
didSessionExpire: function() {
|
didSessionExpire: function() {
|
||||||
// use only to test why user was sent to login page.
|
// use only to test why user was sent to login page.
|
||||||
var response = false;
|
var response = false;
|
||||||
if ($cookieStore.get('token_expire')) {
|
var token_expire = ($rootScope.token_expire) ? $rootScope.token_expire : $cookieStore.get('token_expire');
|
||||||
var exp = new Date($cookieStore.get('token_expire'));
|
if (token_expire) {
|
||||||
|
var exp = new Date(token_expire);
|
||||||
var today = new Date();
|
var today = new Date();
|
||||||
if (exp < today) {
|
if (exp < today) {
|
||||||
response = true;
|
response = true;
|
||||||
@@ -49,7 +53,7 @@ angular.module('AuthService', ['ngCookies'])
|
|||||||
|
|
||||||
getToken: function() {
|
getToken: function() {
|
||||||
if ( this.isTokenValid() ) {
|
if ( this.isTokenValid() ) {
|
||||||
return $cookieStore.get('token');
|
return ($rootScope.token) ? $rootScope.token : $cookieStore.get('token');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return null;
|
return null;
|
||||||
@@ -68,6 +72,8 @@ angular.module('AuthService', ['ngCookies'])
|
|||||||
$cookieStore.remove('token_expire');
|
$cookieStore.remove('token_expire');
|
||||||
$cookieStore.remove('current_user');
|
$cookieStore.remove('current_user');
|
||||||
$rootScope.userLoggedIn = false;
|
$rootScope.userLoggedIn = false;
|
||||||
|
$rootScope.token = null;
|
||||||
|
$rootScope.token_expire = new Date(1970, 0, 1, 0, 0, 0, 0);
|
||||||
},
|
},
|
||||||
|
|
||||||
getLicense: function() {
|
getLicense: function() {
|
||||||
|
|||||||
@@ -12,7 +12,11 @@ angular.module('RestServices',['ngCookies','AuthService'])
|
|||||||
this.url = url;
|
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() {
|
pReplace: function() {
|
||||||
//in our url, replace :xx params with a value, assuming
|
//in our url, replace :xx params with a value, assuming
|
||||||
@@ -33,20 +37,20 @@ angular.module('RestServices',['ngCookies','AuthService'])
|
|||||||
this.pReplace();
|
this.pReplace();
|
||||||
return $http({method: 'GET',
|
return $http({method: 'GET',
|
||||||
url: this.url,
|
url: this.url,
|
||||||
headers: this.auth,
|
headers: this.auth(),
|
||||||
params: this.params
|
params: this.params
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
post: function(data) {
|
post: function(data) {
|
||||||
return $http({method: 'POST',
|
return $http({method: 'POST',
|
||||||
url: this.url,
|
url: this.url,
|
||||||
headers: this.auth,
|
headers: this.auth(),
|
||||||
data: data });
|
data: data });
|
||||||
},
|
},
|
||||||
put: function(data) {
|
put: function(data) {
|
||||||
return $http({method: 'PUT',
|
return $http({method: 'PUT',
|
||||||
url: this.url,
|
url: this.url,
|
||||||
headers: this.auth,
|
headers: this.auth(),
|
||||||
data: data });
|
data: data });
|
||||||
|
|
||||||
},
|
},
|
||||||
@@ -54,7 +58,7 @@ angular.module('RestServices',['ngCookies','AuthService'])
|
|||||||
var url = this.url;
|
var url = this.url;
|
||||||
return $http({method: 'DELETE',
|
return $http({method: 'DELETE',
|
||||||
url: url,
|
url: url,
|
||||||
headers: this.auth,
|
headers: this.auth(),
|
||||||
data: data});
|
data: data});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ angular.module('Utilities',[])
|
|||||||
return function(id) {
|
return function(id) {
|
||||||
var element = document.getElementById(id);
|
var element = document.getElementById(id);
|
||||||
var scope = angular.element(element).scope();
|
var scope = angular.element(element).scope();
|
||||||
scope.$destroy();
|
scope.$destroy();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user