I'm using AngularFire2 authentication. We can log in with email/pass (email has been verified) or log in with Google. If I log in with email everything is fine. I log out, I log in, back and forth no issues. Then I sign in with Google, and log out and also no issues. BUT, if I log in with Google, then log out, I CAN'T log in with email unless I refresh the page! Even tho I'm totally logged out I get "auth/invalid-email" every time I try logging in after logging in with Google and logging out. If I refresh the page I can log in again with email without having any issues. Anyone know what this behavior is?
2 Answers
It is related to this issue: Firebase Overwrites Signin with Google Account
In this particular case, this happens for a security reason. Here is a common scenario. I sign up an email/password account with your gmail address. The account is unverified (emailVerified is false). You then try to sign in with your Google account using the same email which is a verified Google email. If the password I setup still exists, then I can basically sign-in into your account. To protect against this, Firebase Auth will unlink all providers that are unverified.
You can only keep the old password provider if you verify the account by sending an email verification and completing the verification flow before the Google sign-in.
- 29,642
- 4
- 69
- 76
-
Unfortunately this is after it's verified :( – Jus10 Jul 09 '17 at 18:36
I don't know why, but since refreshing the page works, I just refreshed it after logging out with:
location.reload();
Not sure if that's the proper way to do it, but it works! ... and I would be happier if auth.signOut() did the job better.
- 14,519
- 21
- 52
- 77