src/app/guards/skip-multi-factor.guard.ts
Properties |
limits |
limits:
|
Type : LimitsResult
|
Defined in src/app/guards/skip-multi-factor.guard.ts:15
|
state |
state:
|
Type : AppStateModel
|
Defined in src/app/guards/skip-multi-factor.guard.ts:14
|
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;
})
);
}
}