angular / angularfire

Angular + Firebase = ❤️
https://firebaseopensource.com/projects/angular/angularfire2
MIT License
7.69k stars 2.19k forks source link

authGuardPipe seems to be invoked too early in 6.1.0 and 6.1.1 #2681

Closed theolof closed 3 years ago

theolof commented 3 years ago

Version info

Angular: 11.0.0

Firebase: 8.1.1

AngularFire: 6.1.1

How to reproduce these conditions

Steps to set up and reproduce If I use AngularFire 6.1.0 or later, my authGuardPipe seems to be invoked before the user is fully signed in. claims is empty after signin. If I reload the page, claims is populated. This is also the case if I look at the user object.

const redirectToChangePassword = () => pipe(customClaims, map(claims => {
    console.log(claims);
    return claims.hasSetPassword ?? ['/auth/change-password'];
}));
    {
        path        : 'pages',
        loadChildren: () => import('./main/pages/pages.module').then(m => m.PagesModule),
        canActivate: [AngularFireAuthGuard],
        data: { authGuardPipe: redirectToChangePassword },
        resolve: {
            data: AuthService,
        }
    },

6.1.0-rc.4 works as expected, so something has changed between rc.4 and 6.1.0.

jamesdaniels commented 3 years ago

Ah yes, there was a share change after rc.4 that could explain this where I was trying to fix a Zone.js issue with analytics. I'll patch.

jamesdaniels commented 3 years ago

Cutting 6.1.2 this afternoon with a fix.

theolof commented 3 years ago

Thanks, works as expected.