Leul Mekonnen
Leul Mekonnen

Reputation: 3

TypeError: Cannot read property 'credential' of undefined - React-redux-firebase, Firebase Auth

I have been developing a project where the user can change password. I want to reauthenticate the current user using

currentUser.reauthenticateWithCredential(
            firebase
              .auth()
              .EmailAuthProvider.credential(
                currentUser.email,
                credentials.userOldPassword
              )
          )
          .then(() => console.log("authenticated"))
          .catch((error) => console.log(error));

But it gives an error like

Cannot read property 'credential' of undefined

I am using react-redux-firebase

Upvotes: 0

Views: 902

Answers (1)

Frank van Puffelen
Frank van Puffelen

Reputation: 598817

The EmailProvider class is in the auth namespace, not in the auth instance. So the correct syntax is:

firebase
  .auth // no parenthesis here
  .EmailAuthProvider.credential(
    currentUser.email,
    credentials.userOldPassword
  )

Also see the Firebase documentation for the EmailAuthProvider.credential method.

Upvotes: 2

Related Questions