Saccarab
Saccarab

Reputation: 1521

Unexpected `auth/operation-not-allowed` Error When Linking Anonymous Account with Email in Firebase

I'm encountering an unexpected issue when attempting to link an anonymous user with an email/password credential in Firebase. Relevant firebase auth doc

The following code snippet demonstrates the function I'm using to perform the linking:

export function linkAnonWithEmail(email, password) {
  const credential = firebase.auth.EmailAuthProvider.credential(email, password);
  auth.currentUser
    .linkWithCredential(credential)
    .then((result) => {
      // Handle successful linking
    })
    .catch((error) => {
      const errorCode = error.code;
      if (errorCode === 'auth/operation-not-allowed') {
        // This error is being triggered
      }
      // Handle other errors
    });
}

When this function is executed, I get the auth/operation-not-allowed error with the message "Please verify the new email before changing email." This behavior is unexpected, as:

Has anyone else encountered this specific error, or does anyone have insights into why this might be happening? Any help or guidance would be greatly appreciated.

Upvotes: 4

Views: 843

Answers (1)

Toothgip
Toothgip

Reputation: 536

I send an email to Firebase support, it seems there is protection activated by default since September 15, as you can see here.

You have here the process to disable this protection.

Upvotes: 3

Related Questions