Project

General

Profile

« Previous | Next » 

Revision 59816

[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())

View differences:

adminLoginGuard.guard.ts
4 4
import {Session} from './utils/helper.class';
5 5
import {LoginErrorCodes} from './utils/guardHelper.class';
6 6
import {UserManagementService} from "../services/user-management.service";
7
import {filter, map} from "rxjs/operators";
7
import {map, tap} from "rxjs/operators";
8 8

  
9 9
@Injectable()
10 10
export class AdminLoginGuard implements CanActivate {
......
15 15
  
16 16
  check(path: string): Observable<boolean> {
17 17
    let errorCode = LoginErrorCodes.NOT_LOGIN;
18
    const obs = this.userManagementService.getUserInfo(false).pipe(map(user => {
18
    return this.userManagementService.getUserInfo(false).pipe(map(user => {
19 19
      if (user) {
20 20
        errorCode = LoginErrorCodes.NOT_ADMIN;
21 21
      }
22 22
      return Session.isPortalAdministrator(user);
23
    }),tap(isAdmin => {
24
      if(!isAdmin) {
25
        this.router.navigate(['/user-info'], {
26
          queryParams: {
27
            'errorCode': errorCode,
28
            'redirectUrl': path
29
          }
30
        });
31
      }
23 32
    }));
24
    obs.pipe(filter(isAdmin => !isAdmin)).subscribe(() => {
25
      this.router.navigate(['/user-info'], {
26
        queryParams: {
27
          'errorCode': errorCode,
28
          'redirectUrl': path
29
        }
30
      });
31
    });
32
    return obs;
33

  
33 34
  }
34 35
  
35 36
  canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | boolean {

Also available in: Unified diff