fixing the cookies for the login| export claims admin component

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@50677 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
argiro.kokogiannaki 2018-02-12 10:21:42 +00:00
parent f3d4b06b66
commit 2cebe8c6b5
1 changed files with 9 additions and 8 deletions

View File

@ -38,10 +38,9 @@ export class Session{
var user:User = null; var user:User = null;
var cookie= COOKIE.getCookie(COOKIE.cookieName_u); var cookie= COOKIE.getCookie(COOKIE.cookieName_u);
if( typeof localStorage !== 'undefined') { if( typeof localStorage !== 'undefined') {
if(localStorage.getItem("user") && (cookie != null && cookie != "")) { if(localStorage.getItem("user") || (cookie != null && cookie != "")) {
user = JSON.parse(localStorage.getItem("user")); user = JSON.parse(localStorage.getItem("user"));
if(user && (user.fullname != null || user.lastname !=null || user.firstname !=null)){ if(user && (user.fullname != null || user.lastname !=null || user.firstname !=null)){
loggedIn = true; loggedIn = true;
}else if(cookie != null && this.getUserFromCookie()!= null){ }else if(cookie != null && this.getUserFromCookie()!= null){
loggedIn = true loggedIn = true
@ -111,15 +110,11 @@ export class Session{
public static getCurrentParameters():any { public static getCurrentParameters():any {
if( typeof localStorage !== 'undefined') { if( typeof localStorage !== 'undefined') {
var params = localStorage.getItem("params"); var params = localStorage.getItem("params");
console.log(params);
var object = null; var object = null;
if(params.split("&").length > 0){ if(params.split("&").length > 0){
object = {}; object = {};
} }
for(var i=0; i<params.split("&").length; i++){ for(var i=0; i<params.split("&").length; i++){
console.log(params.split("&")[i]);
console.log((params.split("&")[i]).split("=")[0]);
console.log((params.split("&")[i]).split("=")[1]);
object[(params.split("&")[i]).split("=")[0]] = (params.split("&")[i]).split("=")[1]; object[(params.split("&")[i]).split("=")[0]] = (params.split("&")[i]).split("=")[1];
} }
return object; return object;
@ -269,6 +264,12 @@ export class MyJWT{
d.setTime(d.getTime() + expireDays * 24 * 60 * 60 * 1000); d.setTime(d.getTime() + expireDays * 24 * 60 * 60 * 1000);
let expires:string = `expires=${d.toUTCString()}`; let expires:string = `expires=${d.toUTCString()}`;
// let cpath:string = path ? `; path=${path}` : ''; // let cpath:string = path ? `; path=${path}` : '';
document.cookie = name+'='+value+'; path='+path+'; domain='+document.domain+';'; let domain = "";
if(document.domain.indexOf(".di.uoa.gr")!= -1){
domain = ".di.uoa.gr";
}else if(document.domain.indexOf(".openaire.eu") != -1){
domain = ".openaire.eu";
}
document.cookie = name+'='+value+'; path='+path+'; domain='+domain+';';
} }
} }