0

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.

SoleR
  • 13
  • 1
  • 5

1 Answers1

0

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.

Alex Mamo
  • 130,605
  • 17
  • 163
  • 193
  • Thanks for your answer Alex! but I do have a question: At which point in the code do I get the users-email of the user that have clicked on his account through the Google OAuth pop-up, is it in the `onActivityResult()` because if I get that info after it gets created It's kind of odd. No, what I try to do is giving the possibility to the user to use Google SignIn through Google in a LOGIN activity, for creating new account I have setup a SignUp Activity, so yeah, I want to login only the users who have SignUp before. – SoleR Apr 28 '19 at 09:57
  • Yes, you're right, in the onActivityResult(). You're are getting Google account details and after than l then you login Firebase. To login only users who have signed up before, you should check the existence of the user as explained in my above answer. – Alex Mamo Apr 28 '19 at 10:55
  • Sorry I was paying focus on the coding haha, of course! – SoleR Apr 28 '19 at 18:27