我正在尝试更新云 Firestore 中预先存在的信息。这是我的规则:
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
//match logged in user doc in users collection
match /users/{userId} {
allow read, write, update: if request.auth.uid == userId;
allow create: if request.auth.uid != null;
}
}
}
Run Code Online (Sandbox Code Playgroud)
所以我可以通过 userId 读取数据,它在我的网站上读取正常,但是当我尝试更新它时,我收到以下错误消息
error.ts:166 Uncaught (in promise) FirebaseError: Missing or insufficient permissions.
at new hi (https://www.gstatic.com/firebasejs/7.9.3/firebase-firestore.js:1:51421)
at https://www.gstatic.com/firebasejs/7.9.3/firebase-firestore.js:1:316738
at br.<anonymous> (https://www.gstatic.com/firebasejs/7.9.3/firebase-firestore.js:1:315592)
at Jt (https://www.gstatic.com/firebasejs/7.9.3/firebase-firestore.js:1:15221)
at br.I.dispatchEvent (https://www.gstatic.com/firebasejs/7.9.3/firebase-firestore.js:1:16063)
at Nr.ua (https://www.gstatic.com/firebasejs/7.9.3/firebase-firestore.js:1:45312)
at nr.I.Fa (https://www.gstatic.com/firebasejs/7.9.3/firebase-firestore.js:1:43219)
at ze (https://www.gstatic.com/firebasejs/7.9.3/firebase-firestore.js:1:21453)
at qe (https://www.gstatic.com/firebasejs/7.9.3/firebase-firestore.js:1:20854)
at …Run Code Online (Sandbox Code Playgroud)