这些是我目前的安全规则:
service cloud.firestore {
match /databases/{database}/documents {
match /tournaments/{tournament=**} {
allow update, delete: if request.auth.uid == resource.data.author;
allow create: if request.auth.uid != null;
allow read: if true;
}
}
}
一切正常,由于“权限缺失或不足”,只有更新或删除不起作用
这是我的代码
mDocRef
.update(key, score)
.addOnSuccessListener(new OnSuccessListener<Void>() {
@Override
public void onSuccess(Void aVoid) {
Log.d(TAG, "DocumentSnapshot successfully updated!");
}
})
.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Log.w(TAG, "Error updating document", e);
}
});
mDocRef 指的是路径为“tournaments/tournamentID/aColletion/aDocument”的文档
下面是创建 mDocRef 的代码:
mTournamentDocRef = mTournamentColRef.document();
mDocRef = mTournamentDocRef.collection("aCollection").document();
一些注意事项:
感谢您的帮助!
最佳答案
我检查了文档,这些是您正在寻找的规则:
match /users/{userId} {
allow read, update, delete: if request.auth.uid == userId;
allow create: if request.auth.uid != null;
}
和文档链接作为引用:https://firebase.google.com/docs/firestore/security/rules-conditions?authuser=0