[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
This commit is contained in:
argiro.kokogiannaki 2021-01-12 16:18:00 +00:00
parent 28d2affb66
commit 265a8e68d9
2 changed files with 6 additions and 1 deletions

View File

@ -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<boolean> {
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'], {

View File

@ -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;