src/app/guards/skip-multi-factor.guard.ts
Methods |
constructor(router: Router, app: AppState)
|
Defined in src/app/guards/skip-multi-factor.guard.ts:19
|
canActivate |
canActivate()
|
Defined in src/app/guards/skip-multi-factor.guard.ts:21
|
Returns :
Observable<boolean>
|
import { Injectable } from '@angular/core';
import { CanActivate, Router } from '@angular/router';
import { AppState } from '../stores/app-state.store';
import { Observable } from 'rxjs/Observable';
import { LimitsService } from '../services/limits.service';
import { map, zip } from 'rxjs/operators';
import { AppStateModel } from '../models';
import { LimitsResult } from '../models/limits-result.model';
import { of } from 'rxjs/observable/of';
interface Wrapper {
state: AppStateModel;
limits: LimitsResult;
}
@Injectable()
export class SkipMultiFactorGuard implements CanActivate {
constructor(private router: Router, private app: AppState) {}
canActivate(): Observable<boolean> {
return this.app.state$.pipe(
map(state => {
if (state.passMfa) {
console.log('passed skip mfa guard');
// mfa required redirect to mfa component
this.router.navigate(['payment/create']);
return false;
}
console.log('failed skip mfa guard');
return true;
})
);
}
}