Firebase group security rule configuration -
i new firebase, , trying setup security rules want users grouped dynamically created groups. want user able read content same group, not other groups.
when create new users , assign them groups using push, data following:
{ "groups" : { "default" : { "-jtcdyniz1yvwnqcgsar" : { "user" : "simplelogin:5" }, "-jtd114knq-rqh6-rlni" : { "user" : "simplelogin:7" } } }, "users" : { "simplelogin:5" : { "group" : "default", "name" : "123" }, "simplelogin:6" : { "group" : "default1", "name" : "1" }, "simplelogin:7" : { "group" : "default", "name" : "23" } } } can here? how can setup authentication rules? have tried following doesn't seem work...
{ "rules": { "users" : { "$userid" : { ".read" : "data.child('users').child($userid).child('group').val() === data.child('users').child(auth.id).child('group').val()", ".write" : "$userid === auth.uid" } } } } i assume should simple use-case unfortunately didn't help.
whatever posts found had direct users inside group instead of subchild of random, unique string.
edited:
i tried edited rules :
{ "rules": { "groups" : { ".read" : "true", ".write" : "true" }, "users" : { "$userid" : { ".read" : "data.child('group').val() === root.child('users').child(auth.id).child('group').val()", ".write" : "$userid === auth.uid" } } } } but did not help.
for code, have added fiddler @ : http://jsfiddle.net/digish_gabhawala/ytwmokg0/
what want @ moment 2 simple things: 1> user, should able edit name 2> when click button, should able names of users in group.
when tried code in fiddler, getting permission issues.
it great if can doing wrong.
i'm pretty sure issue you're using $userid instead of $uid. changing should make work. i'm using $uid in security rules.
Comments
Post a Comment