7ha*_*ker 4 firebase firebase-authentication
我想知道我是否可以通过电子邮件"查找"用户,而不是以用户身份登录
我想这样做的原因是,只是确定我是否已经是系统的用户,仅使用电子邮件地址
我查看了这个较旧的帖子,但它似乎是以前版本的Firebase
是否有可能做到这一点在目前的火力地堡,或者我的替代方法是保持这些信息的提供(和向所有人开放?),以找出是否一个给定的电子邮件是我的系统的一部分?
Dop*_*pio 13
我使用fetchProvidersForEmail(电子邮件),如果结果返回为空数组,则此电子邮件尚未用于注册.
firebase.auth().fetchProvidersForEmail(email)
.then(providers => {
if (providers.length === 0) {
// this email hasn't signed up yet
} else {
// has signed up
}
});Run Code Online (Sandbox Code Playgroud)
小智 7
您可以通过电子邮件查找用户信息:
\nfirebase.auth().getUserByEmail(email)\n .then(function(userRecord) {\n // See the UserRecord reference doc for the contents of userRecord.\n console.log(\'Successfully fetched user data:\', userRecord.toJSON());\n })\n .catch(function(error) {\n console.log(\'Error fetching user data:\', error);\n });\nRun Code Online (Sandbox Code Playgroud)\n我想让事情更清楚,这个方法不存在 \xe2\x80\x94 人们可能会在 firebase 客户端库中寻找它,在这个库中它从一开始就不可用,而且也不会\'无论如何,拥有这并不是一个好主意。该方法是admin SDK的一部分,因此为了调用该方法,您需要在服务器上运行它,并从客户端调用它。OP 没有将问题范围限定到 firebase 客户端库,所以我的答案仍然是正确的。
\n\n| 归档时间: |
|
| 查看次数: |
6279 次 |
| 最近记录: |