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:

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

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

Also available in: Unified diff