Firebase rule auth.token.email is not working: “Simulated write denied”

六眼飞鱼酱① 提交于 2019-12-04 06:10:30

问题


https://firebase.google.com/docs/reference/security/database/#authtokenF

{
  "rules": {
    "c":{
      ".write":"newData.child('email').val()=== auth.token.email"
    },
   }
}

Always it showing "Simulated write denied"
How to solve this problem ? Is there any mistake with my firebase rule


回答1:


It looks like you're not providing an email address in the authentication data.

When you select a provider, the simulator shows the exact auth.token payload that it will use. For the Google provider my Auth token payload looks like this:

The simulator takes the literal JSON that is shown in here, and uses it as auth.token.

{
  "provider": "google",
  "uid": "27e08474-4e33-460d-ba92-ba437c6aa962"
}

Since there is no email provided, your rules (correctly) fail.

For testing this scenario, you'll want to switch to a custom provider, so that you can specify your own auth token with an email property:



来源:https://stackoverflow.com/questions/49878527/firebase-rule-auth-token-email-is-not-working-simulated-write-denied

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!