首页 > 解决方案 > 是否可以在子目录中使用通配符变量?

问题描述

我一直在为我的 ionic 应用程序制定安全规则,我一直想知道通配符是否可以用作规则中子级的附加目录。

这是我目前拒绝访问错误的规则

"rules": {
    "Download": {

      "$id": {  

        ".read":"root.child('password/'+$id).child('password').val() === 4321"

      }  
    }
}

虽然这是我使用正在工作的完整子目录的规则

"rules": {
    "Download": {

      "$id": {  

        ".read":"root.child('password/12342').child('password').val() === 4321"

      }  
    }
}

这个,是下载节点

Download: {
   4123: {
      id: 01
    user:john
   }
   3123: {
      id: 01
    user:john
   }
}

密码节点

password: {
   12342: {
     password: 4321
     id: 01
   }
}


这个是接收函数,

    let qwee = await new Promise(function(resolve,reject){
       return firebaseRef.child('QuizDownload/3123')
          .on("child_added", function(snapshot) {
              //console.log(snapshot.val());

              //data.push(snapshot.val());
             // data
             console.log(snapshot.val());
             //resolve(data);


              //container.push(snapshot.val());

           }, function(err) {
             console.log(err);
             reject(err);
           })
        }); 


  }

您能否建议使用通配符作为目录的附加错误应该是什么?

标签: firebasefirebase-realtime-databasefirebase-security

解决方案


推荐阅读