Is there a way to store a custom expression in Firebase Rules to be reused? -
i able reuse expression in firebase rules multiple times.
if have following rules:
{ "rules": { ".read": true, ".write": false, "secretarea1": { ".read": "root.child('users').child(auth.uid).child('role').val() === 'admin'", ".write": "root.child('users').child(auth.uid).child('role').val() === 'admin'" }, "secretarea2": { ".read": "root.child('users').child(auth.uid).child('role').val() === 'admin'", ".write": "root.child('users').child(auth.uid).child('role').val() === 'admin'" } } }
is there way store root.child('users').child(auth.uid).child('role').val() === 'admin'
somewhere doesn't have repeated 4 times?
something like:
{ "rules": { ".read": true, ".write": false, "secretarea1": { ".read": "isadmin", ".write": "isadmin" }, "secretarea2": { ".read": "isadmin", ".write": "isadmin" } } }
maybe i'm approaching wrong way. suggestions great!
i discovered blaze compiler linked @ security & rules libraries. not looking , adds compile step seems provide functionality looking for. nice if included option in firebase dashboard.
Comments
Post a Comment