Add expire time and remove useless function
This commit is contained in:
parent
5d8b904a32
commit
fa77d200c5
1 changed files with 7 additions and 14 deletions
|
@ -9,17 +9,6 @@ mainApp.factory('Identity',[ '$http', '$cookies', function($http, $cookies){
|
|||
profile.projectname=null;
|
||||
var token=null;
|
||||
|
||||
|
||||
/**
|
||||
* Save profile in cookies
|
||||
*/
|
||||
var saveCookieForSession=function(){
|
||||
$cookies.putObject('profile', profile);
|
||||
$cookies.putObject('token.part_0', token.part_0);
|
||||
$cookies.putObject('token.part_1', token.part_1);
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* @returns {boolean} Return true if a cookie is found (and load it in profile) false else
|
||||
*/
|
||||
|
@ -87,12 +76,16 @@ mainApp.factory('Identity',[ '$http', '$cookies', function($http, $cookies){
|
|||
// Find the middle of the token to split it
|
||||
var middle=parseInt(response.data.token.length/2);
|
||||
|
||||
// Create expire date (cookie expire in 55 mins)
|
||||
var expireDate=new Date();
|
||||
expireDate.setMinutes(expireDate.getMinutes()+55);
|
||||
|
||||
// Save profile
|
||||
$cookies.putObject('profile', profile);
|
||||
$cookies.putObject('profile', profile, {'expires': expireDate});
|
||||
// Save first part of token
|
||||
$cookies.putObject('token.part_0', response.data.token.substring(0, middle));
|
||||
$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));
|
||||
$cookies.putObject('token.part_1', response.data.token.substring(middle, response.data.token.length), {'expires': expireDate});
|
||||
}
|
||||
else if(failedToSendRequest){
|
||||
requestParserResult.failReason="Failed to send request";
|
||||
|
|
Loading…
Add table
Reference in a new issue