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

痴心易碎 提交于 2019-12-11 14:54:09

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/55881287/how-to-make-android-google-sign-in-button-to-just-login-and-not-register-with-fi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!