summaryrefslogtreecommitdiff
path: root/client/js/services/Identity.js
diff options
context:
space:
mode:
authormanzerbredes <loic.guegan_secondary@yahoo.fr>2016-02-24 14:42:46 +0100
committermanzerbredes <loic.guegan_secondary@yahoo.fr>2016-02-24 14:42:46 +0100
commit7676509fcd6ab0a6c3e666c00c6ff96ecc1f7ffb (patch)
tree4af40ce8a204c43e99bf3026b1db2cf9679d1502 /client/js/services/Identity.js
parentd2f5ae5c83ef5bc41cf430ace79769459b4acbf8 (diff)
parentc511010ec41e57d99d1756780ee968269fa2b8fb (diff)
Merge branch 'loic' into develop
Diffstat (limited to 'client/js/services/Identity.js')
-rw-r--r--client/js/services/Identity.js34
1 files changed, 27 insertions, 7 deletions
diff --git a/client/js/services/Identity.js b/client/js/services/Identity.js
index 8ee664c..0dfba47 100644
--- a/client/js/services/Identity.js
+++ b/client/js/services/Identity.js
@@ -7,14 +7,17 @@ mainApp.factory('Identity',[ '$http', '$cookies', function($http, $cookies){
var profile={};
profile.username=null;
profile.projectname=null;
- profile.token=null;
-
+ var token={};
+ token.part_0=null;
+ token.part_1=null;
/**
* Save profile in cookies
*/
var saveCookieForSession=function(){
- $cookies.putObject('profile', 5);
+ $cookies.putObject('profile', profile);
+ $cookies.putObject('token.part_0', token.part_0);
+ $cookies.putObject('token.part_1', token.part_1);
};
@@ -23,10 +26,17 @@ mainApp.factory('Identity',[ '$http', '$cookies', function($http, $cookies){
*/
var isAlreadyLogin=function(){
var profileInCookie=$cookies.getObject('profile');
- console.log(profileInCookie);
+ var tokenPart_0InCookie=$cookies.getObject('token.part_0');
+ var tokenPart_1InCookie=$cookies.getObject('token.part_0');
+
- if(typeof profileInCookie !== 'undefined'){
+ if(typeof profileInCookie !== 'undefined'
+ && typeof tokenPart_0InCookie !== 'undefined'
+ && typeof tokenPart_1InCookie !== 'undefined'
+ ){
angular.extend(profile, profileInCookie);
+ token.part_0=tokenPart_0InCookie;
+ token.part_1=tokenPart_1InCookie;
return true;
}
@@ -38,6 +48,8 @@ mainApp.factory('Identity',[ '$http', '$cookies', function($http, $cookies){
*/
var logout=function(){
$cookies.remove('profile');
+ $cookies.remove('token.part_0');
+ $cookies.remove('token.part_1');
}
@@ -56,7 +68,11 @@ mainApp.factory('Identity',[ '$http', '$cookies', function($http, $cookies){
if (typeof response.data.token !== 'undefined') {
requestParserResult.status=0;
- profile.token=response.data.token;
+
+ var middle=parseInt(response.data.token.length/2);
+ token.part_0=response.data.token.substring(0, middle);
+ token.part_1=response.data.token.substring(middle, response.data.token.length);
+
saveCookieForSession();
}
else if(failedToSendRequest){
@@ -70,6 +86,9 @@ mainApp.factory('Identity',[ '$http', '$cookies', function($http, $cookies){
};
+ var getToken=function(){
+ return token.part_0+token.part_1;
+ }
/**
* Function to connect to OpenStack
@@ -104,7 +123,8 @@ mainApp.factory('Identity',[ '$http', '$cookies', function($http, $cookies){
login: login,
profile: profile,
isAlreadyLogin: isAlreadyLogin,
- logout:logout
+ logout:logout,
+ getToken:getToken
};