1

I am getting a :

Uncaught TypeError: user.reauthenticate is not a function

with this code below.

var user = firebase.auth().currentUser;
var credentials = firebase.auth.EmailAuthProvider.credential(user.email,'foo');

console.log(user) // the currentUser object
console.log(user.reauthenticate) // undefined    

user.reauthenticate(credentials)
    .then(() => {
        // Do something
    }, err => console.log(error));

I just followed this guide and this accepted answer by Frank van Puffelen.

UmarZaii
  • 1,355
  • 1
  • 17
  • 26
jofftiquez
  • 7,548
  • 10
  • 67
  • 121
  • In the accepted answer I see this `var user = firebase.app.auth().currentUser;` whereas you have `var user = firebase.auth().currentUser;`. – camden_kid Jul 18 '17 at 11:11
  • Can you try `user.reauthenticateWithCredential`? See https://firebase.google.com/docs/reference/js/firebase.User#reauthenticateWithCredential – Frank van Puffelen Jul 18 '17 at 13:49
  • Hello @FrankvanPuffelen `user. reauthenticateWithCredential` worked. I found it yesterday on under the `user` object. Thanks. – jofftiquez Jul 19 '17 at 05:15

1 Answers1

2

firebaser here

We made a breaking change in the 4.0 version of the Firebase Web SDK. From the release notes:

BREAKING: firebase.User.prototype.reauthenticate has been removed in favor of firebase.User.prototype.reauthenticateWithCredential.

As far as I can tell the reauthenticateWithCredentialis a drop-in replacement for the old method.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
  • 1
    Thanks for reporting. Somehow this got missed in the documentation guides. The fix for that is in flight. – Frank van Puffelen Jul 19 '17 at 14:24
  • UPDATE 2023: The link to `firebase.User.prototype.reauthenticateWithCredential` leads to a 404 page. For Firebase v8 docs, go [here](https://firebase.google.com/docs/reference/js/v8/firebase.User#reauthenticatewithcredential). For Firebase v9, apparently you need to `import { reauthenticateWithCredential } from "firebase/auth";`, refer [here](https://stackoverflow.com/questions/69186075/error-with-reauthenticatewithcredential-get-error-typeerror-credential-getreau?rq=3). – Irfan Zainudin Jul 10 '23 at 20:31