Open
Description
Describe your environment
- Operating System version: macOS Big Sur 11.2.3
- Browser version: 89.0.4389.90
- Firebase SDK version: 8.2.10
- Firebase Product: auth
Describe the problem
When we reauthenticate a user using Google auth provider, a user is being added to the Firebase Authentication if we use another account to sign in instead of the previously signed-in user.
Steps to reproduce:
- Sign in a user with Google auth provider by using
signInWithPopup()
method (example user: myid1@gmail.com). - Try to delete this user from a web application.
- Need to reauthenticate the user
myid1@gmail.com
by usingreauthenticateWithPopup()
method. - In the sign-in popup try to give some different google account (example: myid2@gmail.com).
- A new user entry will be added in the Firebase Authentication for the user
myid2@gmail.com
.
Relevant Code:
import * as firebase from 'firebase/app';
const user = firebase.default.auth().currentUser;
user.reauthenticateWithPopup(new firebase.default.auth.GoogleAuthProvider())
.then(() => {
// Success
}).catch((error) => {
//Error: The supplied credentials do not correspond to the previously signed in user.
});
The proper error message (The supplied credentials do not correspond to the previously signed in user.
) is coming in the catch block and also a new user is created which can be avoided.