Use cookie to save the reload url - to share it through different domains/ dashboards
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@52177 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
parent
7ca752f345
commit
707b80ed71
|
@ -120,38 +120,11 @@ export class UserComponent {
|
||||||
queryParams = splits[1];
|
queryParams = splits[1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log("saving url & params...");
|
Session.setReloadUrl(location.protocol +"//"+location.host, baseUrl, queryParams);
|
||||||
console.log(queryParams);
|
|
||||||
Session.setCurrentUrl(baseUrl);
|
|
||||||
Session.setCurrentParameters(queryParams);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
window.location.href = this.properties.loginUrl;
|
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 = "";
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -140,11 +140,7 @@ export class UserMiniComponent {
|
||||||
if(Session.isLoggedIn()){
|
if(Session.isLoggedIn()){
|
||||||
Session.removeUser();
|
Session.removeUser();
|
||||||
console.log("Try to Logout!");
|
console.log("Try to Logout!");
|
||||||
// this.logoutOpenaire.logout().subscribe(params => {
|
// console.log("Redirect to "+location.href);
|
||||||
// console.log("Logout!");
|
|
||||||
// });
|
|
||||||
// logoutClicked();
|
|
||||||
console.log("Redirect to "+location.href);
|
|
||||||
window.location.href = this.logOutUrl + StringUtils.URIEncode(location.href);
|
window.location.href = this.logOutUrl + StringUtils.URIEncode(location.href);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -154,9 +150,8 @@ export class UserMiniComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
logIn(){
|
logIn(){
|
||||||
console.log("LOgin is clicked " + this.logInUrl);
|
// console.log("LOgin is clicked " + this.logInUrl);
|
||||||
Session.setCurrentUrl(location.pathname);
|
Session.setReloadUrl(location.protocol +"//"+location.host, location.pathname, location.search);
|
||||||
Session.setCurrentParameters(location.search);
|
|
||||||
window.location.href = this.logInUrl
|
window.location.href = this.logInUrl
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -122,40 +122,35 @@ export class Session{
|
||||||
// }
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
public static getCurrentUrl():string {
|
|
||||||
if( typeof localStorage !== 'undefined') {
|
|
||||||
return localStorage.getItem("url");
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
|
|
||||||
}
|
public static setReloadUrl(host:string,path:string, params:string) {
|
||||||
public static setCurrentUrl(url:string) {
|
var URL = {};
|
||||||
if( typeof localStorage !== 'undefined') {
|
URL["host"]=host;
|
||||||
localStorage.setItem("url", url);
|
URL["path"]=path;
|
||||||
}
|
URL["params"]=params;
|
||||||
|
COOKIE.setCookie("reloadURL", JSON.stringify(URL), -1);
|
||||||
|
|
||||||
}
|
}
|
||||||
public static getCurrentParameters():any {
|
public static getReloadUrl(plainText:boolean =false) {
|
||||||
if( typeof localStorage !== 'undefined') {
|
var URL = COOKIE.getCookie("reloadURL");
|
||||||
var params = localStorage.getItem("params");
|
URL = JSON.parse(URL);
|
||||||
var object = null;
|
return URL;
|
||||||
|
|
||||||
|
}
|
||||||
|
public static getParamsObj(params:string) {
|
||||||
|
|
||||||
|
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++){
|
||||||
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;
|
||||||
return {};
|
|
||||||
}
|
|
||||||
public static setCurrentParameters(params:string) {
|
|
||||||
if( typeof localStorage !== 'undefined') {
|
|
||||||
if(params.indexOf("?")==0){
|
|
||||||
params = params.substring(1);
|
|
||||||
}
|
|
||||||
localStorage.setItem("params",(params && params.length > 1)? params:"");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static isClaimsCurator():boolean {
|
public static isClaimsCurator():boolean {
|
||||||
var isAuthorized = false;
|
var isAuthorized = false;
|
||||||
var user:User = this.getUserFromCookie();
|
var user:User = this.getUserFromCookie();
|
||||||
|
|
|
@ -35,17 +35,26 @@ export class ReloadComponent {
|
||||||
if (typeof document !== 'undefined') {
|
if (typeof document !== 'undefined') {
|
||||||
this.element.nativeElement.scrollIntoView();
|
this.element.nativeElement.scrollIntoView();
|
||||||
}
|
}
|
||||||
var url = Session.getCurrentUrl();
|
var URL = Session.getReloadUrl();
|
||||||
|
var url = URL["path"];
|
||||||
if(url && url != null && url != ""){
|
if(url && url != null && url != ""){
|
||||||
Session.setCurrentUrl("");
|
var host = URL["host"];
|
||||||
var paramsObject = Session.getCurrentParameters();
|
var paramsObject = Session.getParamsObj(URL["params"]);
|
||||||
Session.setCurrentParameters("");
|
if(host == location.host){
|
||||||
if(paramsObject && paramsObject != null){
|
if(paramsObject && paramsObject != null){
|
||||||
this._router.navigate([url],{ queryParams: paramsObject});
|
Session.setReloadUrl("","","")
|
||||||
|
this._router.navigate([url],{ queryParams: paramsObject});
|
||||||
|
}else{
|
||||||
|
Session.setReloadUrl("","","")
|
||||||
|
this._router.navigate([url]);
|
||||||
|
}
|
||||||
}else{
|
}else{
|
||||||
this._router.navigate([url]);
|
Session.setReloadUrl("","","")
|
||||||
|
window.location.href = host+url+ URL["params"];
|
||||||
}
|
}
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
|
Session.setReloadUrl("","","")
|
||||||
this._router.navigate(['/']);
|
this._router.navigate(['/']);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue