【发布时间】:2016-10-02 02:56:26
【问题描述】:
我找到了这个documentation,它解释了如何将匿名用户与新注册用户联系起来,但我不明白它是如何工作的。
从解释中还找到here,我得到了如下图(如果我错了请纠正我):
- 匿名用户登录:得到userUid(仅举例)
ANONYM-USER-UID - 用户将数据添加到购物车,如下所示:
数据
-- shoppingCart
-- ANONYM-USER-UID
-- <push-id>
-- itemUid: <item-uid>
-- count: 2
-- <push-id>
-- itemUid: <other-item-uid>
-- count: 1
-- OTHER-USER-UID
-- .......
with rule:只有合适的UserId才能访问购物车
"rules": {
"shoppingCart" {
"$userUid": {
".read": "auth.uid == $userUid"
}
}
}
- 结帐前,用户“强制”注册/或登录,
AuthCredential然后被检索,然后linkWithCredential被调用。用户比使用新的用户 UID,例如REGISTERED-USER-UID
问题是,每当客户端代码查询shoppingCart/REGISTERED-USER-UID时,它会检索到shoppingCart/ANONYM-USER-UID的项目列表吗?规则会允许吗?
如果应用更复杂的规则,例如,规则变为 -- 只有合适的 UserId 才能访问购物车,但 userUid 不能在 blackList child。
"rules": {
"shoppingCart" {
"$userUid": {
".read": "auth.uid == $userUid && root.child('blackList').child($userUid).val() == false"
}
}
}
有了这样的逻辑限制,它会成功返回列表吗?
【问题讨论】:
标签: android firebase firebase-authentication firebase-security