Firebase - 检查电子邮件是否被注册的最有效的方法是什么? [英] Firebase - what is the most efficient way to check if an email is registered?
问题描述
我正在尝试编写一个函数,用于在继续注册过程(如果电子邮件未注册)之前检查是否向我的Firebase应用程序(使用Javascript / Web)注册了电子邮件。 / p>
我创建了一个名为 active_emails
的节点,我想用注册的电子邮件(如数组)填充这个节点。我要检查这个列表中的电子邮件,如果它不存在,那么我将允许用户进行注册过程。
我正确地认为上面的答案需要Firebase编译,然后将一组电子邮件发送回用户客户端?这似乎可能会影响性能(如果有成千上万,或数百万的电子邮件文件),它会公开所有用户的电子邮件到客户端?是否有另一种方式来检查用户是否注册,可能类似于尝试注册,然后捕获重复的电子邮件错误(虽然这听起来像一个混乱的方式去做这件事)。
最佳答案在这里:如何找出电子邮件是否已经注册到Firebase简单登录?建议使用 fetchProvidersForEmail
作为一种检查方式来查看是否一个电子邮件注册,但答案是Android的,我不知道是否有可能做这样的事情与JavaScript / Web。
我试过在这里集成这个方法:
$ p $函数checkEmail(){
firebase.database()。ref()。fetchProvidersForEmail() (value,function(snapshot){
console.log(snapshot);
});
}
但显示错误: firebase.database ...)。ref(...)。fetchProvidersForEmail不是一个函数
。有没有人有任何想法,最好的方法来实现这个检查?
预先感谢您!
此方法仅用于身份验证:
firebase.auth()。fetchProvidersForEmail(emailaddress@gmail.com)
I'm trying to write a function that will check to see if an email is registered with my Firebase app (with Javascript/Web), before proceeding with the sign up process (if the email isn't registered).
I created a node named active_emails
which I wanted to populate with registered emails (like an array). I was going to check the email against this list and if it didn't exist then I would allow the user to proceed with the registration process.
I see from the answer here: Proper way to store values array-like in Firebase that Firebase creates keys inside the array. So a normal Javascript array check won't work. I understand how the answer above works, but I was wondering, since I'm essentially doing a look up on the emails of registered Firebase users, is there another way to do this check?
Am I correct in thinking that the answer above requires Firebase to compile and then send an array of emails back to the user client-side? This seems like it might affect performance (if there are hundreds of thousands, or millions of emails on file), and would it expose all user emails to the client? Is there another way to check if a user is registered or not, maybe something like attempting a registration and then catching a duplicate email error (although this sounds like a messy way to go about this).
The top answer here: How to find out if an email is already registered with Firebase Simple Login? suggests using fetchProvidersForEmail
as a way of checking to see if an email is registered, but that answer is for android and I don't know if it's possible to do such a thing with Javascript/Web.
I've tried to integrate this method here:
function checkEmail(){
firebase.database().ref().fetchProvidersForEmail("emailaddress@gmail.com").once("value", function(snapshot) {
console.log(snapshot);
});
}
But it shows the error: firebase.database(...).ref(...).fetchProvidersForEmail is not a function
. Does anybody have any ideas on the best way to go about achieving this check?
Thank you in advance!
This method is for auth only:
firebase.auth().fetchProvidersForEmail("emailaddress@gmail.com")
这篇关于Firebase - 检查电子邮件是否被注册的最有效的方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!