Revision 59816
Added by Argiro Kokogiannaki over 3 years ago
connectAdminLoginGuard.guard.ts | ||
---|---|---|
1 |
import {map, filter, mergeMap} from 'rxjs/operators'; |
|
1 |
import {map, filter, mergeMap, take} from 'rxjs/operators';
|
|
2 | 2 |
import {Injectable} from '@angular/core'; |
3 | 3 |
import { |
4 | 4 |
Router, |
... | ... | |
30 | 30 |
check(community: string, path: string): Observable<boolean> | boolean { |
31 | 31 |
let errorCode = LoginErrorCodes.NOT_LOGIN; |
32 | 32 |
let email = null; |
33 |
const authorized = this.userManagementService.getUserInfo(false).pipe(map(user => { |
|
33 |
const authorized = this.userManagementService.getUserInfo(false).pipe(take(1),map(user => {
|
|
34 | 34 |
if (user) { |
35 | 35 |
email = user.email; |
36 | 36 |
if (Session.isPortalAdministrator(user) || Session.isCommunityCurator(user) || Session.isManager('community', community, user)) { |
... | ... | |
38 | 38 |
} else { |
39 | 39 |
errorCode = LoginErrorCodes.NOT_ADMIN; |
40 | 40 |
return this.communityService.isCommunityManagerByState(properties, properties['communityAPI'] + community, |
41 |
email); |
|
41 |
email).pipe(take(1));
|
|
42 | 42 |
} |
43 | 43 |
} else { |
44 | 44 |
return of(false); |
Also available in: Unified diff
[Library|Trunk]
code clean up:
-remove app.* files from library
-remove unused imports, code, files (Old search pages for results, dataproviders, map search page, etc)
-remove Freeguard from modules
-unsubscribe all subscriptions
-Services: configuration, isvocabularies, user management: unsubscribe from app component or the component that uses them (clearSubscriptions())
-Fetchers: unsubscribe from the component that uses them (clearSubscriptions())