Home:ALL Converter>The email address is badly formatted - Firebase Reauthentication

The email address is badly formatted - Firebase Reauthentication

Ask Time:2021-06-29T17:20:27         Author:Adam Szymański

Json Formatter

Hi guys I have a problem with reauthentication. I'm providing an email from currentUser state and password from popup window.

This is how reauth function looks now:

async function reauthenticate(password: string) {
    try {
      if (currentUser) {
        console.log(currentUser?.email);
        const credential = firebase.auth.EmailAuthProvider.credential(
          currentUser.email!,
          password,
        );
        console.log(credential);
        await currentUser.reauthenticateWithCredential(credential);
        return true;
      }
    } catch (error) {
      console.log(error.message);
      throw 'Please try again';
    }
  }

And this is output from the console. I have no idea why I have a "The email address is badly formatted" error. The provided email doesn't have white spaces.

enter image description here

Any ideas? Thanks :)

Author:Adam Szymański,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/68175903/the-email-address-is-badly-formatted-firebase-reauthentication
yy