diff --git a/connect/connectHelper.ts b/connect/connectHelper.ts index e4c7b07f..b3839a85 100644 --- a/connect/connectHelper.ts +++ b/connect/connectHelper.ts @@ -3,7 +3,7 @@ import {HttpParams} from '@angular/common/http'; export class ConnectHelper { public static getCommunityFromDomain(domain: string): string{ - // domain = "https://mes.openaire.eu"; //for testing + domain = "beta.ee.openaire.eu"; //for testing domain = domain.indexOf("//") != -1? domain.split("//")[1]:domain; //remove https:// prefix if (domain.indexOf('openaire.eu') === -1) { return null; diff --git a/login/userMini.component.ts b/login/userMini.component.ts index 44fdcefd..345c7a51 100644 --- a/login/userMini.component.ts +++ b/login/userMini.component.ts @@ -1,5 +1,5 @@ import {Component, ElementRef, Input, OnChanges, OnInit, SimpleChanges} from '@angular/core'; -import {ActivatedRoute, Router} from '@angular/router'; +import {ActivatedRoute, NavigationStart, Router} from '@angular/router'; import {Location} from '@angular/common'; import {User, Session} from './utils/helper.class'; import {RouterHelper} from '../utils/routerHelper.class'; @@ -176,25 +176,27 @@ export class UserMiniComponent implements OnInit, OnChanges { @Input() logInUrl; @Input() logOutUrl; @Input() cookieDomain; + @Input() fixRedirectUrl: string; @Input() redirectUrl: string; @Input() dark: boolean = false; search: string = ''; sub: any; - constructor(private router: Router, private route: ActivatedRoute, private location: Location) { + constructor(private router: Router, private route: ActivatedRoute) { + this.router.events.forEach(event => { + if(event instanceof NavigationStart) { + this.initialize(event.url); + } + }); } ngOnInit() { - if (typeof document !== 'undefined') { this.server = false; } - this.initialize(); this.sub = this.route.queryParams.subscribe(params => { this.initialize(); }); - - } ngOnChanges(changes: SimpleChanges): void { @@ -209,10 +211,20 @@ export class UserMiniComponent implements OnInit, OnChanges { } } - initialize() { - if (!this.redirectUrl && typeof location !== 'undefined') { - this.redirectUrl = location.pathname; - this.search = location.search; + initialize(url: string = null) { + if (typeof location !== 'undefined') { + if(url) { + let parts = StringUtils.split(url, ['?']); + this.redirectUrl = properties.baseLink + parts[0]; + if(parts.length == 2) { + this.search = parts[1]; + } else { + this.search = null; + } + } else { + this.redirectUrl = location.pathname; + this.search = location.search; + } } if (this.user) { this.loggedIn = true; @@ -230,8 +242,13 @@ export class UserMiniComponent implements OnInit, OnChanges { logOut() { if (this.user) { Session.removeUser(); - window.location.href = this.logOutUrl + StringUtils.URIEncode(location.href); - + // New method + if(properties.logoutUrl.includes('openid_logout')) { + Session.setReloadUrl(location.protocol + "//" + location.host, this.redirectUrl, this.search); + window.location.href = this.logOutUrl; + } else { + window.location.href = this.logOutUrl + StringUtils.URIEncode(location.href); + } } this.loggedIn = false; this.isAuthorized = false; @@ -239,7 +256,8 @@ export class UserMiniComponent implements OnInit, OnChanges { } logIn() { - Session.setReloadUrl(location.protocol + "//" + location.host, this.redirectUrl, this.search); + Session.setReloadUrl(location.protocol + "//" + location.host, + this.fixRedirectUrl?(properties.baseLink + this.fixRedirectUrl):this.redirectUrl, this.search); window.location.href = this.logInUrl; } diff --git a/login/utils/helper.class.ts b/login/utils/helper.class.ts index 96c08c73..af56af51 100644 --- a/login/utils/helper.class.ts +++ b/login/utils/helper.class.ts @@ -13,7 +13,7 @@ export class User { export class Session{ public static removeUser() { COOKIE.deleteCookie(COOKIE.cookieName_id); - COOKIE.deleteCookie("openAIRESession"); + //COOKIE.deleteCookie("openAIRESession"); COOKIE.deleteCookie("openAIREUser"); } diff --git a/reload/reload.component.ts b/reload/reload.component.ts index 64aae728..5d5291c7 100644 --- a/reload/reload.component.ts +++ b/reload/reload.component.ts @@ -4,52 +4,52 @@ import {Session} from '../login/utils/helper.class'; import {HelperFunctions} from "../utils/HelperFunctions.class"; @Component({ - selector: 'reload', - template: ` -