0
考虑以下保护的 “房间” 的数据结构在/rooms/room1
:如何构建Firebase实时数据库规则以允许向非用户发送“邀请”网址以允许访问受保护的用户数据结构?
数据:
{
rooms: {
room1: {
content: "hello world",
authorizedUsers: {
"UidOfUserA": true,
"UidOfUserB": true
}
}
}
}
规则:
{
"rules": {
"rooms": {
"$room": {
".read": "data.child('authorizedUsers').hasChild(auth.uid)",
".write": "data.child('authorizedUsers').hasChild(auth.uid)"
}
}
}
}
目前,UserA和用户B可以读取和写入数据到/rooms/room1
。假设UserA能够允许UserB加入,因为UserA知道UserB的UID。
但是,如果用户A想要邀请尚未拥有帐户的人,则通过生成一个URL并将其发送给朋友(不一定是通过电子邮件),此设计需要扩展。
我怎样才能构建我的规则,以允许这样做?