Skip to content

Commit 481146b

Browse files
author
J Humes
authored
fix(auth-guard): Address zone issues on lazy loaded routes (#2368)
Fix auth guard timing to not cause issues with change detection and other issues on lazy loaded routes.
1 parent 4f50767 commit 481146b

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/auth-guard/auth-guard.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export class AngularFireAuthGuard implements CanActivate {
2424
const auth = of(undefined).pipe(
2525
observeOn(new ɵAngularFireSchedulers(zone).outsideAngular),
2626
switchMap(() => zone.runOutsideAngular(() => import('firebase/auth'))),
27+
observeOn(new ɵAngularFireSchedulers(zone).insideAngular),
2728
map(() => ɵfirebaseAppFactory(options, zone, nameOrConfig)),
2829
map(app => app.auth()),
2930
shareReplay({ bufferSize: 1, refCount: false }),
@@ -56,4 +57,4 @@ export const emailVerified: AuthPipe = map(user => !!user && user.emailVerified)
5657
export const customClaims = pipe(idTokenResult, map(idTokenResult => idTokenResult ? idTokenResult.claims : []));
5758
export const hasCustomClaim = (claim:string) => pipe(customClaims, map(claims => claims.hasOwnProperty(claim)));
5859
export const redirectUnauthorizedTo = (redirect: any[]) => pipe(loggedIn, map(loggedIn => loggedIn || redirect));
59-
export const redirectLoggedInTo = (redirect: any[]) => pipe(loggedIn, map(loggedIn => loggedIn && redirect || true));
60+
export const redirectLoggedInTo = (redirect: any[]) => pipe(loggedIn, map(loggedIn => loggedIn && redirect || true));

0 commit comments

Comments
 (0)