简体   繁体   中英

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

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.

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

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

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.

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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