Firebase 具有 $onAuth 方法,用于侦听客户端身份验证状态的更改。如果客户端通过身份验证,回调将传递一个包含 uid 的对象。这是我的问题:基于这个 uid,我怎样才能得到这个对象的 $id。
这就是我的数据在 firebase 中的样子:
profile {
-K2a7k9GXodDriEZrM3f {
email: "ale@aol.com"
gravatar: "https://www.gravatar.com/avatar/1d52da55055f0c8..."
uid: "3f9e0d53-4e61-472c-8222-7fc9f663969e"
name: "ale"
}
}
我在用
auth.$onAuth(function (authData) {
if (authData) {
authData.profile = //here I want the $id of the object
}
})
我看到我可以对 authData 响应做的就是使用以下方法获取对象的 uid:
$firebaseObject(ref.child('profile').child(authData.uid));
此 authData 不包含对象的 $id(即 -K2a7k9GXodDriEZrM3f)。这就是我正在寻找的,以便让用户的信息可用。有没有办法做到这一点?
谢谢。