简体   繁体   English

如何让Android Google登录按钮只登录而不注册FirebaseAuth?

[英]How to make Android Google Sign In button to just Login and not register with FirebaseAuth?

I have a Login activity with the option to type your email & pass and then login through FirebaseAuth , but it also have a Google Sign In button . 我有一个登录活动,可以选择输入您的电子邮件和通过,然后通过FirebaseAuth登录,但它也有一个Google登录按钮 When I click it and I choose an account that have been already registered everything is correct. 当我点击它并选择已经注册的帐户时,一切都是正确的。 BUT when I click on an account that is not in my Firebase Authentication it's get created ! 但是当我点击不在我的Firebase身份验证中的帐户时 它就会被创建

I have implementing it looking at the official documentation (My code is like in the doc so no need to copy it here) 我已经实现它查看官方文档 (我的代码就像在文档中所以不需要在这里复制它)

What I want is when I click on an account that doesn't exist in my Firebase Authentication inform the user about that it's not possible to use that account because is not registered yet. 我想要的是当我点击我的Firebase身份验证中不存在的帐户时, 告知用户由于尚未注册,因此无法使用该帐户。

Seems like in this GitHub Issue they discuss my problem but I can not see how to do it. 似乎在这个GitHub问题中他们讨论我的问题,但我看不出怎么做。

BUT when I click on an account that is not in my Firebase Authentication it's get created! 但是当我点击不在我的Firebase身份验证中的帐户时,它就会被创建!

This is what the documentation that you have linked in your question does. 这就是您在问题中链接的文档所做的事情。 When you choose an account, doesn't matter if you have signed in earlier or not, it gets Google account details and then creates the Firebase account. 当您选择一个帐户时,无论您是否先前登录过,都会获得Google帐户详细信息,然后创建Firebase帐户。

What I want is when I click on an account that doesn't exist in my Firebase Authentication inform the user about that it's not possible to use that account because is not registered yet. 我想要的是当我点击我的Firebase身份验证中不存在的帐户时,告知用户由于尚未注册,因此无法使用该帐户。

To solve this, everytime a user signs in with user and password, create a record in Cloud Firestore or Firebase realtime database to keep track of each user of your app. 要解决此问题,每次用户使用用户和密码登录时,请在Cloud Firestore或Firebase实时数据库中创建记录,以跟踪应用的每个用户。 Once a user tries to sign-up, just check if the user already exists or not. 用户尝试注册后,只需检查用户是否已存在 If it exists, do your logic accordingly and if not, display the message you want. 如果存在,请相应地执行您的逻辑,如果不存在,则显示所需的消息。 But remember, informing the user that "it's not possible to use that account because is not registered yet" it's not quite correct since this is what the user what is trying to do, to create an account. 但请记住,通知用户“由于尚未注册,因此无法使用该帐户”这不太正确,因为这是用户正在尝试创建的帐户。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM