0

Here is a piece of firebase code:-

async reAuthenticateUser({ email, password }) {
    const user = await this.afAuth.currentUser;
    const credential = (await this.afAuth.signInWithEmailAndPassword(email, password)).credential;
    user.reauthenticateWithCredential(credential); 
}

I am using ionic 5+/Angular and AngularFireAuth. Basically to delete a user we need to reauthenticate the user using the above reuaunthenticateWithCredential Method. I am confused as to what is credential object that needs to be fed. I tried resigning and getting the new credential and feeding to the method for reauthentication but it fails and gives me error :- "reauthenticateWithCredential failed: First argument "credential" must be a valid credential."
Please Guide , thank you.

adit bharadwaj
  • 73
  • 3
  • 12
  • Perhaps related: https://stackoverflow.com/questions/37811684/how-to-create-credential-object-needed-by-firebase-web-user-reauthenticatewith – NanoBit Jun 09 '21 at 15:49
  • unfortunately , i tried the solution mention in the above question. but their is no email auth provider inside the AngularFireAuth from where i can get the credential object. – adit bharadwaj Jun 09 '21 at 16:18

1 Answers1

0

constructor(private ngAuth: AngularFireAuth)

const currentUser = this.ngAuth.currentUser;

credential = EmailAuthProvider.credential(currentUser.email, password);

import {EmailAuthProvider} from 'firebase/auth';