Reputation: 2438
Implement user level data setup using the sample given in this link https://firebase.google.com/docs/database/security/quickstart#sample-rules Want to implement read/write access only at user level keeping read only rule intact on other nodes.
Final Rule written as
{
"rules": {
"users": {
"$uid": {
".read": "$uid === auth.uid",
".write": "$uid === auth.uid"
}
},
".read": "auth != null",
".write": "false"
}
}
Sample database structure
Want to provide read / write access only to users node not others.
Sample JSON Data
{
"zmjilhwtlo":{
"MapData":[
{
"CaseId":"1",
"SectionId":"1"
},
{
"CaseId":"2",
"SectionId":"2"
}
],
"MapDataRoot":[
{
"SrNo":"1",
"IsFav":"0",
"ChapterNo":"data",
"ChapterName":"dad",
"ActId":"dfd",
"SectionName":"dfd",
"Description":"dfd"
}
]
},
"hvbxaotcxw":{
"MapData":[
{
"CaseId":"1",
"SectionId":"1"
},
{
"CaseId":"2",
"SectionId":"2"
}
],
"MapDataRoot":[
{
"SrNo":"1",
"IsFav":"0",
"ChapterNo":"data",
"ChapterName":"dad",
"ActId":"dfd",
"SectionName":"dfd",
"Description":"dfd"
}
]
},
"aundpytdod":{
"MapData":[
{
"CaseId":"1",
"SectionId":"1"
},
{
"CaseId":"2",
"SectionId":"2"
}
],
"MapDataRoot":[
{
"SrNo":"1",
"IsFav":"0",
"ChapterNo":"data",
"ChapterName":"dad",
"ActId":"dfd",
"SectionName":"dfd",
"Description":"dfd"
}
]
},
"embpkeanaj":{
"MapData":[
{
"CaseId":"1",
"SectionId":"1"
},
{
"CaseId":"2",
"SectionId":"2"
}
],
"MapDataRoot":[
{
"SrNo":"1",
"IsFav":"0",
"ChapterNo":"data",
"ChapterName":"dad",
"ActId":"dfd",
"SectionName":"dfd",
"Description":"dfd"
}
]
},
"users":{
}
}
Error screenshots from simulator
Upvotes: 0
Views: 400
Reputation: 598728
Since your security rules don't allow anyone to write to /users
, the write to /users
that you're trying in the emulator is correct rejected. If you want to see if a user can write their own node, you'll want to write to /users/e32bcdf5....
(or whatever their UID is).
Upvotes: 1