作者:风飞满天2602938511 | 来源:互联网 | 2023-08-20 19:09
IamtryingtolettheauthorizedcurrentuserreadandwritetohisowndatatotheFirebasedataba
I am trying to let the authorized current user read and write to his own data to the Firebase database. My security data looks like this:
我试图让授权的当前用户读取和写入他自己的数据到Firebase数据库。我的安全数据如下所示:
{
"features" : {
"-KDUBJIPwvLCK-1lV4bM" : {
"e1fd0ccb-370a-4a6f-86af-87fdf97d25a0" : "een"
},
"-KDUBLUr6K_PMxWkgcof" : {
"e1fd0ccb-370a-4a6f-86af-87fdf97d25a0" : "twee"
}
},
"users" : {
"e1fd0ccb-370a-4a6f-86af-87fdf97d25a0" : {
"email" : "tjalling@horecalife.nl",
"image" : "iVBORw0KGgoAAAANSUhEUgAAASwAAAEsCAYAAAB5fY51AAAAAXNSR0IArs4c6QAA\r\nABxpRE9UAAAA",
"name" : "tjalling dijkstra",
"telephone number" : "06580055"
}
}
}
-KDUBJIPwvLCK-1lV4bM
is an autoId gotten from childByAutoId()
method
-KDUBJIPwvLCK-1lV4bM是从childByAutoId()方法获得的autoId
e1fd0ccb-370a-4a6f-86af-87fdf97d25a0
is a uid (unique user id).
e1fd0ccb-370a-4a6f-86af-87fdf97d25a0是一个uid(唯一用户ID)。
een
is the value of a certain feature.
een是某个特征的价值。
My security rules are:
我的安全规则是:
{
"rules": {
"users": {
"$uid": {
".read": "auth != null && auth.uid == $uid",
".write": "auth != null && auth.uid == $uid"
}
},
"features": {
"$autoId" : {
"$uid": {
".read": "auth != null && auth.uid == $uid",
".write": "auth != null && auth.uid == $uid"
}
}
}
}
}
If I write Firebase rules like this, permission to setValue()
is denied on the features part.
如果我编写这样的Firebase规则,则会在功能部件上拒绝setValue()的权限。
2016-03-22 17:51:27.077 Herodus[884:228445] [Firebase] setValue: or removeValue: at /features/-KDUEEZ4z-FCAoUci-rW failed: permission_denied.
2016-03-22 17:51:27.077 Herodus [884:228445] [Firebase] setValue:或removeValue:at / features / -KDUEEZ4z-FCAoUci-rW failed:permission_denied。
A new feature is added with this code snippet:
此代码段添加了一项新功能:
let featureCOntents= addFeatureTextField.text
if featureContents != "" {
let newFeature: String = featureContents!
let featureDict = [ uid: newFeature]
let ref = DataService.dataService.FEATURE_REF.childByAutoId()
ref.setValue(featureDict)
Somebody, any clue what I am doing wrong here?
有人,任何线索我在这里做错了什么?
1 个解决方案