Revision 55964
Added by Argiro Kokogiannaki almost 5 years ago
connectAdminLoginGuard.guard.ts | ||
---|---|---|
1 |
|
|
2 |
import {map, filter, mergeMap} from 'rxjs/operators'; |
|
1 | 3 |
import { Injectable } from '@angular/core'; |
2 | 4 |
import { |
3 | 5 |
Router, |
4 | 6 |
CanActivate, |
5 | 7 |
ActivatedRouteSnapshot, |
6 | 8 |
RouterStateSnapshot, |
7 |
CanLoad, Route |
|
9 |
CanLoad, Route, UrlSegment
|
|
8 | 10 |
} from '@angular/router'; |
9 |
import {Observable} from 'rxjs/Observable';
|
|
11 |
import {Observable} from 'rxjs'; |
|
10 | 12 |
import {Session} from '../../login/utils/helper.class'; |
11 | 13 |
import {LoginErrorCodes} from '../../login/utils/guardHelper.class'; |
12 | 14 |
import {CommunityService} from '../community/community.service'; |
... | ... | |
25 | 27 |
if (Session.isPortalAdministrator() || Session.isCommunityCurator()) { |
26 | 28 |
return true; |
27 | 29 |
} else { |
28 |
const obs = this.propertiesService.subscribeEnvironment().map(res => res).mergeMap(properties => {
|
|
30 |
const obs = this.propertiesService.subscribeEnvironment().pipe(map(res => res),mergeMap(properties => {
|
|
29 | 31 |
return this.communityService.isCommunityManager(properties, properties['communityAPI'] + community, Session.getUserEmail()); |
30 |
}); |
|
31 |
obs.filter(enabled => !enabled)
|
|
32 |
}),);
|
|
33 |
obs.pipe(filter(enabled => !enabled))
|
|
32 | 34 |
.subscribe(() => this.router.navigate(['/user-info'], { |
33 | 35 |
queryParams: { |
34 | 36 |
'errorCode': errorCode, |
... | ... | |
49 | 51 |
return this.check(route.queryParams['communityId'], state.url); |
50 | 52 |
} |
51 | 53 |
|
52 |
canLoad(route: Route): Observable<boolean> | Promise<boolean> | boolean { |
|
54 |
canLoad(route: Route, segments: UrlSegment[]): Observable<boolean> | Promise<boolean> | boolean {
|
|
53 | 55 |
const path = '/' + route.path + document.location.search; |
54 | 56 |
return this.check(ConnectHelper.getCommunityFromPath(path), path); |
55 | 57 |
} |
Also available in: Unified diff
[Library|Trunk]
Merge into trunk branch angular7 rev 55729