From fa77d200c525d0c53118d5d4d60758880e9ca11c Mon Sep 17 00:00:00 2001 From: manzerbredes Date: Wed, 24 Feb 2016 16:16:19 +0100 Subject: [PATCH] Add expire time and remove useless function --- client/js/services/Identity.js | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/client/js/services/Identity.js b/client/js/services/Identity.js index 2042efd..7604230 100644 --- a/client/js/services/Identity.js +++ b/client/js/services/Identity.js @@ -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";