diff --git a/login/user.component.ts b/login/user.component.ts index 06850132..e6fbc326 100644 --- a/login/user.component.ts +++ b/login/user.component.ts @@ -120,38 +120,11 @@ export class UserComponent { queryParams = splits[1]; } } - console.log("saving url & params..."); - console.log(queryParams); - Session.setCurrentUrl(baseUrl); - Session.setCurrentParameters(queryParams); + Session.setReloadUrl(location.protocol +"//"+location.host, baseUrl, queryParams); } window.location.href = this.properties.loginUrl; } - // login() { - // this.sublogin =this._loginService.authenticate(/*this.user*/this.username, this.password).subscribe( - // data => { - // this.user = data; - // this.loggedIn = true; - // this.username = ""; - // this.password = ""; - // this.errorCode = ""; - // this.redirect(); - // - // }, - // err => { - // console.log(err); - // if(err.status == "404") { - // this.errorMessage = "Wrong username"; - // } else if(err.status == "401") { - // this.errorMessage = "Wrong password"; - // } - // this.username = ""; - // this.password = ""; - // this.errorCode = ""; - // - // } - // ); - // } + } diff --git a/login/userMini.component.ts b/login/userMini.component.ts index 4298bfb1..ae40df91 100644 --- a/login/userMini.component.ts +++ b/login/userMini.component.ts @@ -139,12 +139,8 @@ export class UserMiniComponent { logOut(){ if(Session.isLoggedIn()){ Session.removeUser(); - console.log("Try to Logout!"); - // this.logoutOpenaire.logout().subscribe(params => { - // console.log("Logout!"); - // }); - // logoutClicked(); - console.log("Redirect to "+location.href); + console.log("Try to Logout!"); + // console.log("Redirect to "+location.href); window.location.href = this.logOutUrl + StringUtils.URIEncode(location.href); } @@ -154,9 +150,8 @@ export class UserMiniComponent { } logIn(){ - console.log("LOgin is clicked " + this.logInUrl); - Session.setCurrentUrl(location.pathname); - Session.setCurrentParameters(location.search); + // console.log("LOgin is clicked " + this.logInUrl); + Session.setReloadUrl(location.protocol +"//"+location.host, location.pathname, location.search); window.location.href = this.logInUrl } diff --git a/login/utils/helper.class.ts b/login/utils/helper.class.ts index 54f4d8a6..0cf9f03f 100644 --- a/login/utils/helper.class.ts +++ b/login/utils/helper.class.ts @@ -122,40 +122,35 @@ export class Session{ // } } - public static getCurrentUrl():string { - if( typeof localStorage !== 'undefined') { - return localStorage.getItem("url"); - } - return ""; - } - public static setCurrentUrl(url:string) { - if( typeof localStorage !== 'undefined') { - localStorage.setItem("url", url); - } + public static setReloadUrl(host:string,path:string, params:string) { + var URL = {}; + URL["host"]=host; + URL["path"]=path; + URL["params"]=params; + COOKIE.setCookie("reloadURL", JSON.stringify(URL), -1); + } - public static getCurrentParameters():any { - if( typeof localStorage !== 'undefined') { - var params = localStorage.getItem("params"); - var object = null; + public static getReloadUrl(plainText:boolean =false) { + var URL = COOKIE.getCookie("reloadURL"); + URL = JSON.parse(URL); + return URL; + + } + public static getParamsObj(params:string) { + + var object = null; if(params.split("&").length > 0){ object = {}; } for(var i=0; i 1)? params:""); - } + + return object; + } + public static isClaimsCurator():boolean { var isAuthorized = false; var user:User = this.getUserFromCookie(); diff --git a/reload/reload.component.ts b/reload/reload.component.ts index 16812d8f..55cd55e3 100644 --- a/reload/reload.component.ts +++ b/reload/reload.component.ts @@ -35,17 +35,26 @@ export class ReloadComponent { if (typeof document !== 'undefined') { this.element.nativeElement.scrollIntoView(); } - var url = Session.getCurrentUrl(); + var URL = Session.getReloadUrl(); + var url = URL["path"]; if(url && url != null && url != ""){ - Session.setCurrentUrl(""); - var paramsObject = Session.getCurrentParameters(); - Session.setCurrentParameters(""); - if(paramsObject && paramsObject != null){ - this._router.navigate([url],{ queryParams: paramsObject}); + var host = URL["host"]; + var paramsObject = Session.getParamsObj(URL["params"]); + if(host == location.host){ + if(paramsObject && paramsObject != null){ + Session.setReloadUrl("","","") + this._router.navigate([url],{ queryParams: paramsObject}); + }else{ + Session.setReloadUrl("","","") + this._router.navigate([url]); + } }else{ - this._router.navigate([url]); + Session.setReloadUrl("","","") + window.location.href = host+url+ URL["params"]; } + }else{ + Session.setReloadUrl("","","") this._router.navigate(['/']); }