Firebase数据库规则:.exists()始终为true

时间:2019-08-21 16:34:48

标签: javascript firebase web firebase-realtime-database firebase-security

我正试图允许人们在游戏中推荐朋友。添加多个朋友有一个好处,我正努力避免添加随机用户名。因此,我想检查一下,然后再将用户添加到他们的列表中,表明该用户实际存在并且该用户使用了他们的推荐代码进行了签名。

这是我的数据库结构的示例:

$input = $request->all();
if (!empty($input['liability_last_payment_date'])) {
    $new_date = date_create_from_format("m/d/y",$input['liability_last_payment_date']);
    $input['liability_last_payment_date'] = $new_date->format("Y-m-d");
}
$installments_debts_liability->update($input);

因此,具有上述结构;

当某人注册时,会设置一个好友引荐来源。这是引荐他们的朋友的“帐户uid” 。我想做的是将当前用户uid添加为好友的子代>推荐好友。

因此,假设用户"friends": { "qwerty12345": { "friend1": {}, "friend2": {}, "friend3": {}, "friend4": {}, } }, "users": { "qwerty12345": {}, "salamander12345": {}, "harrypotter12345": {} } 从其朋友pikachu12345发送的链接中进行了注册。结构如下:

qwerty12345

我只想添加到"friends": { "qwerty12345": { "pikachu12345": {}, } }, 中,如果 friends > qwerty12345 > pikachu12345中存在qwerty12345

我设置了以下规则:

users
  

编辑:newData.child('account_uid')。val()=引用正在传递的数据对象(如下),其值为"friends": { "$user": { ".write": "$user === newData.child('account_uid').val() && root.child('users').child(newData.child('account_uid').val()).exists()" } },

但是,当我将引荐朋友设置为{strong>不存在时,users表中存在的qwerty12345。仍将其添加到朋友树中。

为什么总是评估为真?

edit,如果相关,则使用Cloud Function编写:

hercule12345

0 个答案:

没有答案
相关问题