-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Firestore - token doesn't update in the Firestore Rules #1499
Comments
@sanks instead of signing out and signing back in, are you able to work around this by reloading the user? |
@morganchen12 no, reloading user doesn't help as well. |
This is a known issue. Right now the Firestore SDK ignores token changes if the uid doesn't change. We likely need to rework the code here: firebase-ios-sdk/Firestore/core/src/firebase/firestore/auth/firebase_credentials_provider_apple.mm Line 61 in 49f2493
Sorry for the inconvenience! For now, signing out / back-in is the only workaround. |
See firebase/firebase-ios-sdk#1499 This reworks our UserListener into a CredentialChangeListener which fires on any token change, even if the User did not change. This allows us to restart our streams (but not switch mutation queues, etc.) on token changes.
[Port of firebase/firebase-js-sdk#1120] Fixes #1499. This reworks our "user listener" into a "credential change listener" that fires on any token change, even if the User did not change. This allows us to restart our streams (but not switch mutation queues, etc.) on token changes.
[Port of firebase/firebase-js-sdk#1120] Fixes #1499. This reworks our "user listener" into a "credential change listener" that fires on any token change, even if the User did not change. This allows us to restart our streams (but not switch mutation queues, etc.) on token changes.
* firebase-ios-sdk/1499: Restart streams on any token change. See firebase/firebase-ios-sdk#1499 This reworks our UserListener into a CredentialChangeListener which fires on any token change, even if the User did not change. This allows us to restart our streams (but not switch mutation queues, etc.) on token changes.
The problem
After setup custom claims for a user through the Cloud Functions - the token (and custom claims together with it) weren't updated in Firestore Rules.
Even after calling
getIDTokenForcingRefresh(true)
the Rule doesn't allow to get a document. However, in the app, I see that the token was updated and contains my custom claim.Only sign out and sign in again helps. But it's not good for the user...
The problem is exactly and only with Firestore Rules section. I checked the Storage Rules section with the similar rules - and the token/custom claims were updated here. Also, I checked the Cloud Functions context - the token/custom claims were updated here as well.
Steps to reproduce:
getIDTokenForcingRefresh(true)
Relevant Code:
Firestore Rules:
Cloud Function:
Function call and token refresh
The text was updated successfully, but these errors were encountered: