I\'m trying to build an AuthGuard for Angular 2 routes using Firebase Auth.
This is the AuthGuard Service:
import { Injectable } from \'@
Complete the observable using .take(1) to make the component render.
import {Observable} from "rxjs/Observable";
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/take';
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
return this.af.auth.map((auth) => {
if (!auth) {
this.router.navigateByUrl('login');
return false;
}
return true;
}).take(1);
}