From 265a8e68d9d96924de51326e7fed0d005750dcf6 Mon Sep 17 00:00:00 2001 From: "argiro.kokogiannaki" Date: Tue, 12 Jan 2021 16:18:00 +0000 Subject: [PATCH] [Connect|Trunk] - connect subscriber: fix previous commit - revert reading community from domain git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@60220 d315682c-612b-4755-9ff5-7f18f6832af3 --- connect/communityGuard/connectSubscriber.guard.ts | 5 +++++ connect/connectHelper.ts | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/connect/communityGuard/connectSubscriber.guard.ts b/connect/communityGuard/connectSubscriber.guard.ts index bd197eda..e043b341 100644 --- a/connect/communityGuard/connectSubscriber.guard.ts +++ b/connect/communityGuard/connectSubscriber.guard.ts @@ -5,6 +5,7 @@ import {Observable} from 'rxjs'; import {LoginErrorCodes} from '../../login/utils/guardHelper.class'; import {SubscribeService} from "../../utils/subscribe/subscribe.service"; import {properties} from "../../../../environments/environment"; +import {ConnectHelper} from "../connectHelper"; @Injectable() export class ConnectSubscriberGuard implements CanActivate { @@ -14,6 +15,10 @@ export class ConnectSubscriberGuard implements CanActivate { check(community: string, path: string): Observable { let errorCode = LoginErrorCodes.NOT_SUBSCRIBER; + let communityDomain = ConnectHelper.getCommunityFromDomain(properties.domain); + if (communityDomain) { + community = communityDomain; + } return this.subscribeService.isSubscribedToCommunity(properties, community).pipe(take(1), tap(subscribed =>{ if(!subscribed){ this.router.navigate(['/user-info'], { diff --git a/connect/connectHelper.ts b/connect/connectHelper.ts index 0c218706..f2201496 100644 --- a/connect/connectHelper.ts +++ b/connect/connectHelper.ts @@ -4,7 +4,7 @@ import {properties} from "../../../environments/environment"; export class ConnectHelper { public static getCommunityFromDomain(domain: string): string{ - domain = "beta.covid-19.openaire.eu"; //for testing + // domain = "beta.covid-19.openaire.eu"; //for testing domain = domain.indexOf("//") != -1? domain.split("//")[1]:domain; //remove https:// prefix if (domain.indexOf('openaire.eu') === -1) { return null;