【问题标题】:How to make firebase Realtime database writable according to authentic users如何根据真实用户使firebase实时数据库可写
【发布时间】:2020-11-24 14:58:05
【问题描述】:

我正在制作一个 android 应用程序,任何人都可以读取数据,但只有真实用户(我们在实时数据库中添加为具有电子邮件 ID 的“用户”)可以修改或添加。我希望除了真正的用户之外没有人可以在他/她的数据库中写入。其他人只能阅读。

这是我的数据库结构:-

【问题讨论】:

标签: java android firebase-realtime-database firebase-authentication


【解决方案1】:

你的规则可能是

 {
  "rules": {
    "some_path": {
      "$uid": {
        // Allow only authenticated content owners access to their data
        ".read": "request.auth != null && request.auth.uid == $uid"
        ".write": "request.auth != null && request.auth.uid == $uid"
      }
    }
  }
}

【讨论】:

    猜你喜欢
    • 2020-04-20
    • 2021-07-03
    • 2021-11-17
    • 2019-03-22
    • 2020-03-04
    • 1970-01-01
    • 2018-03-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多