Clean Identity service
This commit is contained in:
parent
d74a6b510c
commit
f1628e280a
1 changed files with 12 additions and 1 deletions
|
@ -48,6 +48,9 @@ mainApp.factory('Identity',[ '$http', '$cookies', function($http, $cookies){
|
||||||
$cookies.remove('profile');
|
$cookies.remove('profile');
|
||||||
$cookies.remove('token.part_0');
|
$cookies.remove('token.part_0');
|
||||||
$cookies.remove('token.part_1');
|
$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});
|
$cookies.putObject('token.part_0', response.data.token.substring(0, middle), {'expires': expireDate});
|
||||||
// Save second part of token
|
// Save second part of token
|
||||||
$cookies.putObject('token.part_1', response.data.token.substring(middle, response.data.token.length), {'expires': expireDate});
|
$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){
|
else if(failedToSendRequest){
|
||||||
requestParserResult.failReason="Failed to send request";
|
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 {string} projectname The user project name
|
||||||
* @param {function} function to call when data is avalaible
|
* @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)
|
// Set profile information (early)
|
||||||
profile.username=username;
|
profile.username=username;
|
||||||
|
@ -120,6 +127,9 @@ mainApp.factory('Identity',[ '$http', '$cookies', function($http, $cookies){
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get the profile
|
* Get the profile
|
||||||
*/
|
*/
|
||||||
|
@ -133,6 +143,7 @@ mainApp.factory('Identity',[ '$http', '$cookies', function($http, $cookies){
|
||||||
var getToken=function(){
|
var getToken=function(){
|
||||||
return token;
|
return token;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Return services objects
|
// Return services objects
|
||||||
|
|
Loading…
Add table
Reference in a new issue