I am currently working on developing a registration form that utilizes Firebase auth for authentication.
There are two methods available for registering users:
- Using Email / Password Provider
- Using Google Auth Provider
Here is the process I follow:
Step 1: Initially, I register using the Email/Password provider and an account is created successfully.
Image after creating user with Email / Password
Step 2:
Next, if a user tries to login using Google with the same email account using signInWithPopup
, the current provider (Email/Password) gets replaced with Google. Subsequently, trying to log in using Email/Password authentication does not work because it has been replaced with Google.
What I need is:
- When attempting to create a user with
signInWithPopup
, check if the user already exists and immediately redirect to the dashboard without replacing the Email/Password Provider.
Or
- Show an error message stating
Email is already registered using Email/Password. Try logging in using Email/Password
The project uses NextJS with Typescript and here is the full code snippet:
<!-- Code snippet omitted for brevity -->
Tried incorporating fetchSignInMethodsForEmail
method within signInWithPopup
but encountered unresolved issues.