mirror of
https://github.com/ansible/awx.git
synced 2026-03-21 19:07:39 -02:30
Merge pull request #5618 from jaredevantabor/upgrade-cookieStore
updating $cookieStore to $cookie
This commit is contained in:
@@ -232,12 +232,12 @@ var tower = angular.module('Tower', [
|
|||||||
// })
|
// })
|
||||||
}
|
}
|
||||||
])
|
])
|
||||||
.run(['$stateExtender', '$q', '$compile', '$cookieStore', '$rootScope', '$log', '$stateParams',
|
.run(['$stateExtender', '$q', '$compile', '$cookies', '$rootScope', '$log', '$stateParams',
|
||||||
'CheckLicense', '$location', 'Authorization', 'LoadBasePaths', 'Timer',
|
'CheckLicense', '$location', 'Authorization', 'LoadBasePaths', 'Timer',
|
||||||
'ClearScope', 'LoadConfig', 'Store', 'pendoService', 'Prompt', 'Rest',
|
'ClearScope', 'LoadConfig', 'Store', 'pendoService', 'Prompt', 'Rest',
|
||||||
'Wait', 'ProcessErrors', '$state', 'GetBasePath', 'ConfigService',
|
'Wait', 'ProcessErrors', '$state', 'GetBasePath', 'ConfigService',
|
||||||
'FeaturesService', '$filter', 'SocketService',
|
'FeaturesService', '$filter', 'SocketService',
|
||||||
function($stateExtender, $q, $compile, $cookieStore, $rootScope, $log, $stateParams,
|
function($stateExtender, $q, $compile, $cookies, $rootScope, $log, $stateParams,
|
||||||
CheckLicense, $location, Authorization, LoadBasePaths, Timer,
|
CheckLicense, $location, Authorization, LoadBasePaths, Timer,
|
||||||
ClearScope, LoadConfig, Store, pendoService, Prompt, Rest, Wait,
|
ClearScope, LoadConfig, Store, pendoService, Prompt, Rest, Wait,
|
||||||
ProcessErrors, $state, GetBasePath, ConfigService, FeaturesService,
|
ProcessErrors, $state, GetBasePath, ConfigService, FeaturesService,
|
||||||
@@ -339,7 +339,7 @@ var tower = angular.module('Tower', [
|
|||||||
// capture most recent URL, excluding login/logout
|
// capture most recent URL, excluding login/logout
|
||||||
$rootScope.lastPath = $location.path();
|
$rootScope.lastPath = $location.path();
|
||||||
$rootScope.enteredPath = $location.path();
|
$rootScope.enteredPath = $location.path();
|
||||||
$cookieStore.put('lastPath', $location.path());
|
$cookies.put('lastPath', $location.path());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Authorization.isUserLoggedIn() === false) {
|
if (Authorization.isUserLoggedIn() === false) {
|
||||||
@@ -405,7 +405,7 @@ var tower = angular.module('Tower', [
|
|||||||
// User not authenticated, redirect to login page
|
// User not authenticated, redirect to login page
|
||||||
$location.path('/login');
|
$location.path('/login');
|
||||||
} else {
|
} else {
|
||||||
var lastUser = $cookieStore.get('current_user'),
|
var lastUser = $cookies.getObject('current_user'),
|
||||||
timestammp = Store('sessionTime');
|
timestammp = Store('sessionTime');
|
||||||
if (lastUser && lastUser.id && timestammp && timestammp[lastUser.id] && timestammp[lastUser.id].loggedIn) {
|
if (lastUser && lastUser.id && timestammp && timestammp[lastUser.id] && timestammp[lastUser.id].loggedIn) {
|
||||||
var stime = timestammp[lastUser.id].time,
|
var stime = timestammp[lastUser.id].time,
|
||||||
|
|||||||
@@ -15,20 +15,20 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
export default
|
export default
|
||||||
['$http', '$rootScope', '$location', '$cookieStore', 'GetBasePath', 'Store', '$q',
|
['$http', '$rootScope', '$location', '$cookies', 'GetBasePath', 'Store', '$q',
|
||||||
'$injector',
|
'$injector',
|
||||||
function ($http, $rootScope, $location, $cookieStore, GetBasePath, Store, $q,
|
function ($http, $rootScope, $location, $cookies, GetBasePath, Store, $q,
|
||||||
$injector) {
|
$injector) {
|
||||||
return {
|
return {
|
||||||
setToken: function (token, expires) {
|
setToken: function (token, expires) {
|
||||||
// set the session cookie
|
// set the session cookie
|
||||||
$cookieStore.remove('token');
|
$cookies.remove('token');
|
||||||
$cookieStore.remove('token_expires');
|
$cookies.remove('token_expires');
|
||||||
$cookieStore.remove('userLoggedIn');
|
$cookies.remove('userLoggedIn');
|
||||||
$cookieStore.put('token', token);
|
$cookies.put('token', token);
|
||||||
$cookieStore.put('token_expires', expires);
|
$cookies.put('token_expires', expires);
|
||||||
$cookieStore.put('userLoggedIn', true);
|
$cookies.put('userLoggedIn', true);
|
||||||
$cookieStore.put('sessionExpired', false);
|
$cookies.put('sessionExpired', false);
|
||||||
$rootScope.token = token;
|
$rootScope.token = token;
|
||||||
$rootScope.userLoggedIn = true;
|
$rootScope.userLoggedIn = true;
|
||||||
$rootScope.token_expires = expires;
|
$rootScope.token_expires = expires;
|
||||||
@@ -38,14 +38,14 @@ export default
|
|||||||
isUserLoggedIn: function () {
|
isUserLoggedIn: function () {
|
||||||
if ($rootScope.userLoggedIn === undefined) {
|
if ($rootScope.userLoggedIn === undefined) {
|
||||||
// Browser refresh may have occurred
|
// Browser refresh may have occurred
|
||||||
$rootScope.userLoggedIn = $cookieStore.get('userLoggedIn');
|
$rootScope.userLoggedIn = $cookies.get('userLoggedIn');
|
||||||
$rootScope.sessionExpired = $cookieStore.get('sessionExpired');
|
$rootScope.sessionExpired = $cookies.get('sessionExpired');
|
||||||
}
|
}
|
||||||
return $rootScope.userLoggedIn;
|
return $rootScope.userLoggedIn;
|
||||||
},
|
},
|
||||||
|
|
||||||
getToken: function () {
|
getToken: function () {
|
||||||
return ($rootScope.token) ? $rootScope.token : $cookieStore.get('token');
|
return ($rootScope.token) ? $rootScope.token : $cookies.get('token');
|
||||||
},
|
},
|
||||||
|
|
||||||
retrieveToken: function (username, password) {
|
retrieveToken: function (username, password) {
|
||||||
@@ -83,17 +83,17 @@ export default
|
|||||||
scope.$destroy();
|
scope.$destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
if($cookieStore.get('lastPath')==='/portal'){
|
if($cookies.get('lastPath')==='/portal'){
|
||||||
$cookieStore.put( 'lastPath', '/portal');
|
$cookies.put( 'lastPath', '/portal');
|
||||||
$rootScope.lastPath = '/portal';
|
$rootScope.lastPath = '/portal';
|
||||||
}
|
}
|
||||||
else if ($cookieStore.get('lastPath') !== '/home' || $cookieStore.get('lastPath') !== '/' || $cookieStore.get('lastPath') !== '/login' || $cookieStore.get('lastPath') !== '/logout'){
|
else if ($cookies.get('lastPath') !== '/home' || $cookies.get('lastPath') !== '/' || $cookies.get('lastPath') !== '/login' || $cookies.get('lastPath') !== '/logout'){
|
||||||
// do nothing
|
// do nothing
|
||||||
$rootScope.lastPath = $cookieStore.get('lastPath');
|
$rootScope.lastPath = $cookies.get('lastPath');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// your last path was home
|
// your last path was home
|
||||||
$cookieStore.remove('lastPath');
|
$cookies.remove('lastPath');
|
||||||
$rootScope.lastPath = '/home';
|
$rootScope.lastPath = '/home';
|
||||||
}
|
}
|
||||||
x = Store('sessionTime');
|
x = Store('sessionTime');
|
||||||
@@ -102,17 +102,17 @@ export default
|
|||||||
}
|
}
|
||||||
Store('sessionTime', x);
|
Store('sessionTime', x);
|
||||||
|
|
||||||
if ($cookieStore.get('current_user')) {
|
if ($cookies.getObject('current_user')) {
|
||||||
$rootScope.lastUser = $cookieStore.get('current_user').id;
|
$rootScope.lastUser = $cookies.getObject('current_user').id;
|
||||||
}
|
}
|
||||||
ConfigService.delete();
|
ConfigService.delete();
|
||||||
SocketService.disconnect();
|
SocketService.disconnect();
|
||||||
$cookieStore.remove('token_expires');
|
$cookies.remove('token_expires');
|
||||||
$cookieStore.remove('current_user');
|
$cookies.remove('current_user');
|
||||||
$cookieStore.remove('token');
|
$cookies.remove('token');
|
||||||
$cookieStore.put('userLoggedIn', false);
|
$cookies.put('userLoggedIn', false);
|
||||||
$cookieStore.put('sessionExpired', false);
|
$cookies.put('sessionExpired', false);
|
||||||
$cookieStore.put('current_user', {});
|
$cookies.putObject('current_user', {});
|
||||||
$rootScope.current_user = {};
|
$rootScope.current_user = {};
|
||||||
$rootScope.license_tested = undefined;
|
$rootScope.license_tested = undefined;
|
||||||
$rootScope.userLoggedIn = false;
|
$rootScope.userLoggedIn = false;
|
||||||
@@ -163,11 +163,11 @@ export default
|
|||||||
setUserInfo: function (response) {
|
setUserInfo: function (response) {
|
||||||
// store the response values in $rootScope so we can get to them later
|
// store the response values in $rootScope so we can get to them later
|
||||||
$rootScope.current_user = response.results[0];
|
$rootScope.current_user = response.results[0];
|
||||||
$cookieStore.put('current_user', response.results[0]); //keep in session cookie in the event of browser refresh
|
$cookies.putObject('current_user', response.results[0]); //keep in session cookie in the event of browser refresh
|
||||||
},
|
},
|
||||||
|
|
||||||
restoreUserInfo: function () {
|
restoreUserInfo: function () {
|
||||||
$rootScope.current_user = $cookieStore.get('current_user');
|
$rootScope.current_user = $cookies.getObject('current_user');
|
||||||
},
|
},
|
||||||
|
|
||||||
getUserInfo: function (key) {
|
getUserInfo: function (key) {
|
||||||
@@ -177,7 +177,7 @@ export default
|
|||||||
return $rootScope.current_user[key];
|
return $rootScope.current_user[key];
|
||||||
}
|
}
|
||||||
this.restoreUserInfo();
|
this.restoreUserInfo();
|
||||||
cu = $cookieStore.get('current_user');
|
cu = $cookies.getObject('current_user');
|
||||||
return cu[key];
|
return cu[key];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -12,8 +12,8 @@
|
|||||||
|
|
||||||
|
|
||||||
export default
|
export default
|
||||||
['$rootScope', 'Alert', 'Rest', 'GetBasePath', 'ProcessErrors', '$cookieStore',
|
['$rootScope', 'Alert', 'Rest', 'GetBasePath', 'ProcessErrors', '$cookies',
|
||||||
function ($rootScope, Alert, Rest, GetBasePath, ProcessErrors, $cookieStore) {
|
function ($rootScope, Alert, Rest, GetBasePath, ProcessErrors, $cookies) {
|
||||||
return function (params) {
|
return function (params) {
|
||||||
// set PermissionAddAllowed to true or false based on user access. admins and org admins are granted
|
// set PermissionAddAllowed to true or false based on user access. admins and org admins are granted
|
||||||
// accesss.
|
// accesss.
|
||||||
@@ -22,7 +22,7 @@ export default
|
|||||||
me;
|
me;
|
||||||
|
|
||||||
// uer may have refreshed the browser, in which case retrieve current user info from session cookie
|
// uer may have refreshed the browser, in which case retrieve current user info from session cookie
|
||||||
me = ($rootScope.current_user) ? $rootScope.current_user : $cookieStore.get('current_user');
|
me = ($rootScope.current_user) ? $rootScope.current_user : $cookies.getObject('current_user');
|
||||||
|
|
||||||
if (me.is_superuser) {
|
if (me.is_superuser) {
|
||||||
scope.PermissionAddAllowed = true;
|
scope.PermissionAddAllowed = true;
|
||||||
|
|||||||
@@ -22,9 +22,9 @@
|
|||||||
* @description
|
* @description
|
||||||
*/
|
*/
|
||||||
export default
|
export default
|
||||||
['$rootScope', '$cookieStore', 'CreateDialog', 'Authorization',
|
['$rootScope', '$cookies', 'CreateDialog', 'Authorization',
|
||||||
'Store', '$interval', '$state', '$q', 'i18n',
|
'Store', '$interval', '$state', '$q', 'i18n',
|
||||||
function ($rootScope, $cookieStore, CreateDialog, Authorization,
|
function ($rootScope, $cookies, CreateDialog, Authorization,
|
||||||
Store, $interval, $state, $q, i18n) {
|
Store, $interval, $state, $q, i18n) {
|
||||||
return {
|
return {
|
||||||
|
|
||||||
@@ -81,7 +81,7 @@ export default
|
|||||||
}
|
}
|
||||||
this.sessionTime = 0;
|
this.sessionTime = 0;
|
||||||
this.clearTimers();
|
this.clearTimers();
|
||||||
$cookieStore.put('sessionExpired', true);
|
$cookies.put('sessionExpired', true);
|
||||||
},
|
},
|
||||||
|
|
||||||
moveForward: function () {
|
moveForward: function () {
|
||||||
@@ -101,7 +101,7 @@ export default
|
|||||||
y[$rootScope.current_user.id] = x;
|
y[$rootScope.current_user.id] = x;
|
||||||
Store('sessionTime' , y);
|
Store('sessionTime' , y);
|
||||||
$rootScope.sessionExpired = false;
|
$rootScope.sessionExpired = false;
|
||||||
$cookieStore.put('sessionExpired', false);
|
$cookies.put('sessionExpired', false);
|
||||||
this.startTimers();
|
this.startTimers();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -54,11 +54,11 @@
|
|||||||
* This is usage information.
|
* This is usage information.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export default ['$log', '$cookieStore', '$compile', '$window', '$rootScope',
|
export default ['$log', '$cookies', '$compile', '$window', '$rootScope',
|
||||||
'$location', 'Authorization', 'ToggleClass', 'Alert', 'Wait', 'Timer',
|
'$location', 'Authorization', 'ToggleClass', 'Alert', 'Wait', 'Timer',
|
||||||
'Empty', 'ClearScope', '$scope', 'pendoService', 'ConfigService',
|
'Empty', 'ClearScope', '$scope', 'pendoService', 'ConfigService',
|
||||||
'CheckLicense', 'FeaturesService', 'SocketService',
|
'CheckLicense', 'FeaturesService', 'SocketService',
|
||||||
function ($log, $cookieStore, $compile, $window, $rootScope, $location,
|
function ($log, $cookies, $compile, $window, $rootScope, $location,
|
||||||
Authorization, ToggleClass, Alert, Wait, Timer, Empty, ClearScope,
|
Authorization, ToggleClass, Alert, Wait, Timer, Empty, ClearScope,
|
||||||
scope, pendoService, ConfigService, CheckLicense, FeaturesService,
|
scope, pendoService, ConfigService, CheckLicense, FeaturesService,
|
||||||
SocketService) {
|
SocketService) {
|
||||||
@@ -70,13 +70,13 @@ export default ['$log', '$cookieStore', '$compile', '$window', '$rootScope',
|
|||||||
}, 1000);
|
}, 1000);
|
||||||
};
|
};
|
||||||
|
|
||||||
scope.sessionExpired = (Empty($rootScope.sessionExpired)) ? $cookieStore.get('sessionExpired') : $rootScope.sessionExpired;
|
scope.sessionExpired = (Empty($rootScope.sessionExpired)) ? $cookies.get('sessionExpired') : $rootScope.sessionExpired;
|
||||||
scope.login_username = '';
|
scope.login_username = '';
|
||||||
scope.login_password = '';
|
scope.login_password = '';
|
||||||
|
|
||||||
|
|
||||||
lastPath = function () {
|
lastPath = function () {
|
||||||
return (Empty($rootScope.lastPath)) ? $cookieStore.get('lastPath') : $rootScope.lastPath;
|
return (Empty($rootScope.lastPath)) ? $cookies.get('lastPath') : $rootScope.lastPath;
|
||||||
};
|
};
|
||||||
|
|
||||||
lastUser = function(){
|
lastUser = function(){
|
||||||
|
|||||||
@@ -55,8 +55,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
export default
|
export default
|
||||||
['$http', '$rootScope', '$cookieStore', '$q', 'Authorization',
|
['$http', '$rootScope', '$cookies', '$q', 'Authorization',
|
||||||
function ($http, $rootScope, $cookieStore, $q, Authorization) {
|
function ($http, $rootScope, $cookies, $q, Authorization) {
|
||||||
return {
|
return {
|
||||||
|
|
||||||
headers: {},
|
headers: {},
|
||||||
|
|||||||
@@ -179,8 +179,8 @@ angular.module('Utilities', ['RestServices', 'Utilities', 'sanitizeFilter'])
|
|||||||
* @methodOf shared.function:Utilities
|
* @methodOf shared.function:Utilities
|
||||||
* @description For handling errors that are returned from the API
|
* @description For handling errors that are returned from the API
|
||||||
*/
|
*/
|
||||||
.factory('ProcessErrors', ['$rootScope', '$cookieStore', '$log', '$location', 'Alert', 'Wait',
|
.factory('ProcessErrors', ['$rootScope', '$cookies', '$log', '$location', 'Alert', 'Wait',
|
||||||
function($rootScope, $cookieStore, $log, $location, Alert, Wait) {
|
function($rootScope, $cookies, $log, $location, Alert, Wait) {
|
||||||
return function(scope, data, status, form, defaultMsg) {
|
return function(scope, data, status, form, defaultMsg) {
|
||||||
var field, fieldErrors, msg, keys;
|
var field, fieldErrors, msg, keys;
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
|
|||||||
Reference in New Issue
Block a user