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:
parent
f3d4b06b66
commit
2cebe8c6b5
|
@ -1,5 +1,5 @@
|
|||
import {StringUtils} from '../../utils/string-utils.class';
|
||||
|
||||
|
||||
export class User {
|
||||
email:string;
|
||||
firstname: string;
|
||||
|
@ -38,10 +38,9 @@ export class Session{
|
|||
var user:User = null;
|
||||
var cookie= COOKIE.getCookie(COOKIE.cookieName_u);
|
||||
if( typeof localStorage !== 'undefined') {
|
||||
if(localStorage.getItem("user") && (cookie != null && cookie != "")) {
|
||||
if(localStorage.getItem("user") || (cookie != null && cookie != "")) {
|
||||
user = JSON.parse(localStorage.getItem("user"));
|
||||
if(user && (user.fullname != null || user.lastname !=null || user.firstname !=null)){
|
||||
|
||||
loggedIn = true;
|
||||
}else if(cookie != null && this.getUserFromCookie()!= null){
|
||||
loggedIn = true
|
||||
|
@ -111,15 +110,11 @@ export class Session{
|
|||
public static getCurrentParameters():any {
|
||||
if( typeof localStorage !== 'undefined') {
|
||||
var params = localStorage.getItem("params");
|
||||
console.log(params);
|
||||
var object = null;
|
||||
if(params.split("&").length > 0){
|
||||
object = {};
|
||||
}
|
||||
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];
|
||||
}
|
||||
return object;
|
||||
|
@ -269,6 +264,12 @@ export class MyJWT{
|
|||
d.setTime(d.getTime() + expireDays * 24 * 60 * 60 * 1000);
|
||||
let expires:string = `expires=${d.toUTCString()}`;
|
||||
// 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+';';
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue