如何使Android Google登录按钮仅登录而不注册FirebaseAuth? [英] How to make Android Google Sign In button to just Login and not register with FirebaseAuth?

查看:107
本文介绍了如何使Android Google登录按钮仅登录而不注册FirebaseAuth?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个登录活动,可以选择键入您的电子邮件&通过,然后通过 FirebaseAuth 登录,但它还具有一个 Google登录按钮. 当我单击它并选择一个已经注册的帐户时,一切正确.但是,当我单击Firebase身份验证中的帐户不是时,它会被创建!

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. 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!

我已经在官方文档中实现了它 (我的代码就像在文档中一样,因此无需在此处复制)

I have implementing it looking at the official documentation (My code is like in the doc so no need to copy it here)

我想要的是,当我单击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.

似乎在 GitHub问题中,他们讨论了我的问题,但是我可以不知道该怎么做.

Seems like in this GitHub Issue they discuss my problem but I can not see how to do it.

推荐答案

但是,当我单击不在Firebase身份验证中的帐户时,它将被创建!

BUT when I click on an account that is not in my Firebase Authentication it's get created!

这是您在问题中链接的文档的作用.选择帐户后,无论您是否早先登录都无所谓,它会获取Google帐户详细信息,然后创建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.

我想要的是,当我单击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.

要解决此问题,每当用户使用用户名和密码登录时,请在Cloud Firestore或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. 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.

这篇关于如何使Android Google登录按钮仅登录而不注册FirebaseAuth?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆