mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 21:27:40 +00:00
GUAC-932: Remove use of localStorageUtility where possible. Use cookies for auth data.
This commit is contained in:
@@ -23,12 +23,13 @@
|
||||
/**
|
||||
* A service for authenticating a user against the REST API.
|
||||
*/
|
||||
angular.module('auth').factory('authenticationService', ['$http', '$injector',
|
||||
function authenticationService($http, $injector) {
|
||||
angular.module('auth').factory('authenticationService', ['$http', '$cookieStore',
|
||||
function authenticationService($http, $cookieStore) {
|
||||
|
||||
var localStorageUtility = $injector.get("localStorageUtility");
|
||||
var service = {};
|
||||
|
||||
|
||||
var AUTH_COOKIE_ID = "GUAC_AUTH";
|
||||
|
||||
/**
|
||||
* Makes a request to authenticate a user using the token REST API endpoint,
|
||||
* returning a promise that can be used for processing the results of the call.
|
||||
@@ -49,8 +50,10 @@ angular.module('auth').factory('authenticationService', ['$http', '$injector',
|
||||
password: password
|
||||
})
|
||||
}).success(function success(data, status, headers, config) {
|
||||
localStorageUtility.set('authToken', data.authToken);
|
||||
localStorageUtility.set('userID', data.userID);
|
||||
$cookieStore.put(AUTH_COOKIE_ID, {
|
||||
authToken : data.authToken,
|
||||
userID : data.userID
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
@@ -73,7 +76,8 @@ angular.module('auth').factory('authenticationService', ['$http', '$injector',
|
||||
* @returns {String} The user ID of the current user.
|
||||
*/
|
||||
service.getCurrentUserID = function getCurrentUserID() {
|
||||
return localStorageUtility.get('userID');
|
||||
var authData = $cookieStore.get(AUTH_COOKIE_ID);
|
||||
return authData && authData.userID;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -83,7 +87,8 @@ angular.module('auth').factory('authenticationService', ['$http', '$injector',
|
||||
* @returns {String} The auth token associated with the current user.
|
||||
*/
|
||||
service.getCurrentToken = function getCurrentToken() {
|
||||
return localStorageUtility.get('authToken');
|
||||
var authData = $cookieStore.get(AUTH_COOKIE_ID);
|
||||
return authData && authData.authToken;
|
||||
};
|
||||
|
||||
return service;
|
||||
|
Reference in New Issue
Block a user