Clean Identity service

This commit is contained in:
manzerbredes 2016-03-01 20:20:05 +01:00
parent d74a6b510c
commit f1628e280a

View file

@ -48,6 +48,9 @@ mainApp.factory('Identity',[ '$http', '$cookies', function($http, $cookies){
$cookies.remove('profile');
$cookies.remove('token.part_0');
$cookies.remove('token.part_1');
token=null;
profile.username=null;
profile.projectname=null;
}
@ -81,6 +84,10 @@ mainApp.factory('Identity',[ '$http', '$cookies', function($http, $cookies){
$cookies.putObject('token.part_0', response.data.token.substring(0, middle), {'expires': expireDate});
// Save second part of token
$cookies.putObject('token.part_1', response.data.token.substring(middle, response.data.token.length), {'expires': expireDate});
// Put token in var
token=response.data.token;
}
else if(failedToSendRequest){
requestParserResult.failReason="Failed to send request";
@ -102,7 +109,7 @@ mainApp.factory('Identity',[ '$http', '$cookies', function($http, $cookies){
* @param {string} projectname The user project name
* @param {function} function to call when data is avalaible
*/
var login=function(username, password,projectname, callback){
var login=function(username, password,projectname,callback){
// Set profile information (early)
profile.username=username;
@ -120,6 +127,9 @@ mainApp.factory('Identity',[ '$http', '$cookies', function($http, $cookies){
};
/*
* Get the profile
*/
@ -135,6 +145,7 @@ mainApp.factory('Identity',[ '$http', '$cookies', function($http, $cookies){
}
// Return services objects
return {
login: login,