[英]Firebase restrict access to owner
假設我正在使用firebase創建一個博客,每個posts
都有多個authors
。
因此,有一個posts
集合和一個具有以下規則的authors
集合:
我有兩個問題,首先,我應該使用哪個數據庫模式?
authors
集合和一個單獨的posts
集合 authors
集合,每個作者都嵌入了posts
其次,我應該使用哪種安全規則?
{
"rules": {
".read": true,
".write": true
}
// to complete ..
}
第一:你可以使用ng-show,ng-hide,但這不是最好的解決方案。 以下是DoubleClick Campaign Manager如何處理用戶身份驗證的鏈接。 https://docs.google.com/file/d/0B4F6Csor-S1cNThqekp4NUZCSmc/edit
第二:你可以用這種方式編寫你的規則 - 下面,根據需要改變數值。
{
"rules": {
"products": {
".read": true,
".write": true
},
"sectest": {
".read": true,
".write": "(newData.child('admin').child(auth.uid).exists()) ||
(data.exists() && data.child('admin').child(auth.uid).val() == auth.uid) ||
(root.child('users/'+auth.uid+'/isadmin').exists())"
},
"users": {
".write": true,
"$uid": {
".read": "auth != null && auth.uid == $uid"
}
},
"venders": {
".read": true,
".write": true
},
"channels": {
".read": true,
".write": true
}
}
}
看看這個angular-blog示例: https : //github.com/yearofmoo/hexo-angular-blog-example
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.