FirebaseExtended / FirebaseExtended/reactfire

Permission error when accessing a cached firestore collection after logout/login

未关闭
#485 4 条评论 10 个 reaction 已指派 0 人 在 GitHub 查看
v5
主要语言
TypeScript
星标
3.6k
派生
403
平均合并
14 小时 53 分钟
30 天内合并 PR
5

描述

### Version info

**React:** 17.0.2

**Firebase:** 9.4.0

**ReactFire:** 4.2.0

**Other (e.g. Node, browser, operating system) (if applicable):** Chrome, Windows 10

### Test case

Test cases seem challenging to produce since a firebase instance is involved.

### Steps to reproduce

1. Sign In (I used `GoogleAuthProvider`), or be already signed-in.
2. Read from a collection.
3. Sign Out
4. Sign In
5. Read from the same collection.

### Expected behavior

The same data is read.

### Actual behavior

`Uncaught FirebaseError: Missing or insufficient permissions.` is thrown.

This seems to be caused by the global cache of collections. The problem can be mitigated by:
* Refreshing the page after sign out
* Changing the `idField` passed to `useFirestoreCollectionData`. Any easy way to test this is to use `id-${auth.stsTokenManager.expirationTime}` as your `idField`, since `expirationTime` changes on every Sign Out/In cycle.

Note that waiting more than 30 seconds does not fix the problem. So, the cache resetting of the collection is insufficient to resolve the issue. I suspect that the collection is associated with the stale auth token which has been disabled due to logout.

A possible resolution might be to purge the cache on sign out.

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。