ユーザーがトークン (招待状) を持っている場合にのみアカウントを作成できるようにしたい。私のfirebase Securityには次のものがあります:
{
"rules": {
".read": false,
".write": false,
"users": {
// allow to write if in the invitations there is child equal to token from newData()
".write":"root.child('invitations').hasChild(newData.child('token').val())",
},
"invitations":{
"$invitation":{
".read": "true"
}
}
}
}
コメントにあるように、招待状に newData() からのトークンに等しい子がある場合、書き込みを許可したいです。
シミュレーターから:
Attempt to write {"token":"evl6yky3vi0pmn29","name":"John"} to /users/99 with auth=null
/:.write: "false"
=> false
/users:.write: "root.child('invitations').hasChild(newData.child('token').val())"
6:52: hasChild() expects a string argument.
=> false
/users/99:<no rules>
どうすればいいですか?