I have a generic function that I use called isAuthType which takes a single input argument and the return value is the result of a ternary operator:
function isAuthType(type) {
return (type == 'type1' ? true : root.users[auth.uid].type == type);
}
That function is used as a rule, and I would expect the following input/output:
path /path/A {
read() = isAuth('type1')
}
path /path/B {
read() = isAuthType('admin')
}
//Expected rules
"rules": {
"path": {
"A": {
".read": true
},
"B": {
".read": root.child('users').child(auth.uid).child('type').val() == 'admin'
},
}
}
However, the ternary operator, which can be evaluated (in some cases, I can see that it wouldn't if it was based on non-explicit variable), is not evaluated and I'm left with the following, clunky rules:
"rules": {
"path": {
"A": {
".read": 'type1' == 'type1' ? true : root.child('users').child(auth.uid).child('type').val() == 'admin'
},
"B": {
".read": 'admin' == 'type1' ? true : root.child('users').child(auth.uid).child('type').val() == 'admin'
},
}
}
I'll probably separate this into two functions in the meantime to clean things up, but having these evaluate would be handy.