diff --git a/connect/communityGuard/communityError.module.ts b/connect/communityGuard/communityError.module.ts deleted file mode 100644 index 5310e783..00000000 --- a/connect/communityGuard/communityError.module.ts +++ /dev/null @@ -1,19 +0,0 @@ -import {NgModule} from '@angular/core'; -import {CommonModule} from '@angular/common'; -import {FormsModule} from '@angular/forms'; - -import {CommunityErrorPageComponent} from './communityErrorPage.component'; - -@NgModule({ - imports: [ - CommonModule, FormsModule - ], - providers: [], - declarations: [ - CommunityErrorPageComponent - ], - exports: [ - CommunityErrorPageComponent - ] -}) -export class CommunityErrorModule { } diff --git a/connect/communityGuard/communityErrorPage.component.ts b/connect/communityGuard/communityErrorPage.component.ts deleted file mode 100644 index d1cff994..00000000 --- a/connect/communityGuard/communityErrorPage.component.ts +++ /dev/null @@ -1,49 +0,0 @@ -import {Component, OnInit} from '@angular/core'; -import {Location} from '@angular/common'; -import {ActivatedRoute} from '@angular/router'; -import {Title, Meta} from '@angular/platform-browser'; - -@Component({ - selector: 'community-error', - template: ` -
-
-
- -
-

- There is no community selected or the requested page is not available at this type of community! -

-
-

- If you are a community manager, click to manage from user menu. -

-
-
-
-
- ` -}) - -export class CommunityErrorPageComponent implements OnInit { - public page: string; - - constructor (private _location: Location, private _meta: Meta, - private _title: Title, private route: ActivatedRoute) { - - const title = 'OpenAIRE | Error page'; - - this._meta.updateTag({content: title}, "property='og:title'"); - this._title.setTitle(title); - this.page = _location.path(true); - } - - ngOnInit() { - this.route.queryParams.subscribe(data => { - this.page = data['page']; - if (!this.page) { - this.page = this._location.path(true); - } - }); - } -} diff --git a/connect/communityGuard/connectAdminLoginGuard.guard.ts b/connect/communityGuard/connectAdminLoginGuard.guard.ts index 790f6f4a..7a7836cc 100644 --- a/connect/communityGuard/connectAdminLoginGuard.guard.ts +++ b/connect/communityGuard/connectAdminLoginGuard.guard.ts @@ -1,27 +1,22 @@ -import {map, filter, mergeMap, take} from 'rxjs/operators'; +import {filter, map, mergeMap, take} from 'rxjs/operators'; import {Injectable} from '@angular/core'; import { - Router, - CanActivate, ActivatedRouteSnapshot, + CanActivate, + CanActivateChild, + Router, RouterStateSnapshot, - CanLoad, Route, UrlSegment, CanActivateChild, UrlTree + UrlTree } from '@angular/router'; -import {Observable, of, Subscription} from 'rxjs'; +import {Observable, of} from 'rxjs'; import {Session} from '../../login/utils/helper.class'; import {LoginErrorCodes} from '../../login/utils/guardHelper.class'; -import {CommunityService} from '../community/community.service'; -import {EnvironmentSpecificService} from '../../utils/properties/environment-specific.service'; -import {ConnectHelper} from '../connectHelper'; -import {StringUtils} from '../../utils/string-utils.class'; import {UserManagementService} from "../../services/user-management.service"; -import {properties} from "../../../../environments/environment"; @Injectable() export class ConnectAdminLoginGuard implements CanActivate, CanActivateChild { constructor(private router: Router, - private propertiesService: EnvironmentSpecificService, private userManagementService: UserManagementService) { } diff --git a/connect/communityGuard/isCommunityOrAdmin.ts b/connect/communityGuard/isCommunityOrAdmin.ts deleted file mode 100644 index eea25847..00000000 --- a/connect/communityGuard/isCommunityOrAdmin.ts +++ /dev/null @@ -1,62 +0,0 @@ -import {Injectable} from '@angular/core'; -import {ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot} from '@angular/router'; -import {Observable} from 'rxjs'; -import {filter, map, mergeMap, take} from "rxjs/operators"; -import {UserManagementService} from "../../services/user-management.service"; -import {EnvironmentSpecificService} from "../../utils/properties/environment-specific.service"; -import {Session} from "../../login/utils/helper.class"; - -@Injectable() -export class IsCommunityOrAdmin implements CanActivate { - - constructor(private router: Router, - private userManagementService: UserManagementService, - private propertiesService: EnvironmentSpecificService) { - } - /* - //TODO add login guard and simplify this method - check(community: string): Observable | boolean { - return this.userManagementService.getUserInfo(false).pipe(take(1),map(user => { - if (community && community !== 'undefined' || Session.isPortalAdministrator(user)) { - return true; - } else { - this.router.navigate(['/errorCommunity']); - return false; - } - })); - } - */ - check(community: string): Observable | boolean { - if (community && community !== 'undefined') { - return true; - } else { - const obs = this.propertiesService.subscribeEnvironment().pipe(mergeMap(properties => { - return this.userManagementService.getUserInfo(false).pipe(map(user => { - return Session.isPortalAdministrator(user); - })); - })); - obs.pipe(filter( isAdmin => !isAdmin)).subscribe( () => { - this.router.navigate(['/errorCommunity']); - }); - return obs; - } - } -/* - check(community: string): Observable | boolean { - if(Session.isLoggedIn() && Session.isPortalAdministrator()) { - return true; - } - else if (community && community !== 'undefined') { - return true; - } else { - this.router.navigate(['errorcommunity']); - return false; - } - }*/ - - canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable | boolean { - return this.check(route.queryParams['communityId']); - } - -} - diff --git a/dashboard/divhelpcontent/div-help-contents.module.ts b/dashboard/divhelpcontent/div-help-contents.module.ts index 550bfc70..ce65330c 100644 --- a/dashboard/divhelpcontent/div-help-contents.module.ts +++ b/dashboard/divhelpcontent/div-help-contents.module.ts @@ -1,8 +1,6 @@ import {NgModule} from '@angular/core'; import {RouterModule} from '@angular/router'; import {CommonModule} from '@angular/common'; -import {IsCommunity} from '../../connect/communityGuard/isCommunity.guard'; -import {ConnectAdminLoginGuard} from '../../connect/communityGuard/connectAdminLoginGuard.guard'; import {FormsModule, ReactiveFormsModule} from '@angular/forms'; import {AlertModalModule} from '../../utils/modal/alertModal.module'; import {SafeHtmlPipeModule} from '../../utils/pipes/safeHTMLPipe.module'; diff --git a/dashboard/helpTexts/page-help-contents.module.ts b/dashboard/helpTexts/page-help-contents.module.ts index 30f04793..5ae6bfc4 100644 --- a/dashboard/helpTexts/page-help-contents.module.ts +++ b/dashboard/helpTexts/page-help-contents.module.ts @@ -1,8 +1,6 @@ import {NgModule} from '@angular/core'; import {RouterModule} from '@angular/router'; import {CommonModule} from '@angular/common'; -import {IsCommunity} from '../../connect/communityGuard/isCommunity.guard'; -import {ConnectAdminLoginGuard} from '../../connect/communityGuard/connectAdminLoginGuard.guard'; import {FormsModule, ReactiveFormsModule} from '@angular/forms'; import {AlertModalModule} from '../../utils/modal/alertModal.module'; import {PageHelpContentsComponent} from './page-help-contents.component'; @@ -28,7 +26,6 @@ import {HTMLToStringPipeModule} from '../../utils/pipes/HTMLToStringPipe.module' declarations: [ PageHelpContentsComponent ], - providers: [IsCommunity, ConnectAdminLoginGuard], exports: [PageHelpContentsComponent] }) export class PageHelpContentsModule {