我有一个用户具有以下自定义用户声明,
customClaims: { role: 'admin' },
如何在云 Firestore 规则中访问此角色属性(管理员)?
我正在使用下面的代码,但它不起作用。需要做什么才能工作?
match /companies/{document=**} {
allow read: if request.auth != null;
allow write: if request.auth != null && request.customClaims.role == "admin";
}
自定义声明位于request.auth.token
中提到的对象文档 https://firebase.google.com/docs/reference/rules/rules.firestore.Request#auth:
match /companies/{document=**} {
allow read: if request.auth != null;
allow write: if request.auth != null && request.auth.token.role == "admin";
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)