Firebase database rules only two out of three conditions work -


i have "uid" database (uid root each user). try share "uid" roots between users, , want give read access "uid" root in 1 of 3 cases: 1. user access owner. 2. user access located in "uid\permitted_users" of target root. 3. user access located in "uid\temp_users" of target root.

to accomplish created next rule:

".read" : "$uid === auth.uid || (root.child(root.child(auth.uid).child('pre_share').val()).child('temp_users').haschild(root.child(auth.uid).child('temp_permit').val()) || root.child(root.child(auth.uid).child('current_share').val()).child('permitted_users').haschild(auth.uid))" 

but disapointed discover first 2 conditions checked, , third not. (i changed order of conditions , every time access using first 2 in row).

is there way solve this?

edit:

adding db example: sharing user

enter image description here

so after lots of tests found problem. code deletes pre_share temp_users, , when rule tries access val() of non existent pre_share gets null pointer exception. bad firebase doesn't write exception, save me lots of time...

".read" : "$uid === auth.uid ||                    (root.child(auth.uid).haschild('pre_share') &&                    root.child(root.child(auth.uid).child('pre_share').val()).haschild('temp_users') &&                    root.child(auth.uid).haschild('temp_permit') &&                    root.child(root.child(auth.uid).child('pre_share').val()).child('temp_users').haschild(root.child(auth.uid).child('temp_permit').val())) ||                    (root.child(auth.uid).haschild('current_share') &&                    root.child(root.child(auth.uid).child('current_share').val()).haschild('permitted_users') &&                    root.child(root.child(auth.uid).child('current_share').val()).child('permitted_users').haschild(auth.uid))" 

Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -