【发布时间】:2017-12-18 15:33:13
【问题描述】:
我正在尝试写一个文档,但是得到了
权限缺失或不足。
我的规则如下:
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if request.auth.uid == resource.data.uid;
}
}
}
我正在努力写作
const accountBalanceRef = db.collection('accountBalances').doc()
accountBalanceRef.set({
type: s.type,
accountName: s.accountName,
startingBalance: s.startingBalance,
endingBalance: s.endingBalance,
statementYear: s.year,
statementMonth: s.monthNumber,
createdAt: now,
uid: this.props.uid
})
怎么了? this.props.uid 是我的用户名
已解决:
在@Bob Snyder 的帮助下,我用以下规则解决了这个问题
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read: if request.auth.uid == resource.data.uid;
allow write: if request.auth.uid == request.resource.data.uid;
}
}
}
我需要有不同的读写规则。我认为这是因为阅读,我没有设置request.resource.data.uid
【问题讨论】:
标签: firebase google-cloud-firestore