分配自定义声明时,客户端中的用户必须先注销并登录,然后声明才会显示在其帐户上。我今天花了一整天的时间试图找出为什么我的声明没有生效,结果用户必须重新登录才能让声明无缘无故地显示 LOL rip 我一天中的 5 个小时。我可以添加什么内容来刷新用户信息而无需重新登录吗?
最佳答案
可以通过调用currentUser.getIdToken(true)
强制刷新自定义声明。
来自文档...
Propagate custom claims to the client
After new claims are modified on a user via the Admin SDK, they are propagated to an authenticated user on the client side via the ID token in the following ways:
- A user signs in or re-authenticates after the custom claims are modified. The ID token issued as a result will contain the latest claims.
- An existing user session gets its ID token refreshed after an older token expires.
- An ID token is force refreshed by calling
currentUser.getIdToken(true)
.
关于javascript - Firebase:自定义声明要求我的用户注销并登录才能生效?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60272993/