1 回答

TA貢獻1799條經驗 獲得超9個贊
您可以使用我創建的以下函數來執行此操作
function isUserAuthenticated() {
return request.auth.uid != null;
}
function belongsTo(userId) {
return request.auth.uid == userId;
}
然后你可以像這樣使用它:
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if false;
}
match /codes/{userId} {
allow read : if isUserAuthenticated();
allow create : if belongsTo(userId);
allow update: if belongsTo(userId);
allow delete: if belongsTo(userId);
}
/* Functions */
function isUserAuthenticated() {
return request.auth.uid != null;
}
function belongsTo(userId) {
return request.auth.uid == userId;
}
}
}
如果它適合您,請接受作為答案??稍谠u論中了解更多問題。
添加回答
舉報