Description
This issue is kinda related to #2637 since it deals with the same end result.
I figured this bug deserves its own issue though, because it seems so be related to Firestore this time.
Version info
Angular:
10.2.0
Firebase:
8.0.1
AngularFire:
6.1.0-rc.3
How to reproduce these conditions
Failing test unit, Stackblitz demonstrating the problem
https://github.com/jornetsimon/af-auth-debug
Updated with commit reproducing the issue.
Steps to set up and reproduce
- Set up the Authentication & Firestore emulators using the new 6.1 injection tokens.
- Set up an authentication method (email/password for example) and implement it on a page
- Subscribe to authState
- Inject AngularFireStore on a separate routed component (lets call it ComponentB)
- Sign up : no issue
- Reload the app, navigate to ComponentB :
- Now load the app directly on the route pointing to ComponentB (e.g. /componentb): a call to Firebase servers (googleapis.com) is made, returning a 400 INVALID_ID_TOKEN error. The user is therefore logged out.
Sample data and security rules
Providers config:`
providers: [
{
provide: USE_FIRESTORE_EMULATOR,
useValue: environment.useEmulators ? ['localhost', 8888] : undefined,
},
{
provide: USE_AUTH_EMULATOR,
useValue: environment.useEmulators ? ['localhost', 9099] : undefined,
},
],
Debug output
Expected behavior
The AngularFirestore service should target the emulator to verify the auth token.
Actual behavior
There is no problem when authenticating THEN navigating to a component using the AngularFirestore service.
But when loading the app directly through the firestore component endpoint, it seems like it doesn't have the time to be aware of the emulator config...
Note : The issue is the same with 6.1.0-rc.2 and 6.1.0-rc.3.