Skip to content

[πŸ›] πŸ”₯ Firebase Auth - No error when trying to change email to existing accountΒ #8732

@daniel-alsen

Description

@daniel-alsen

Issue

Firebase Authentication

I'm using the verifyBeforeUpdateEmail function that will automatically change the user email address after verification (clicking the email link in the new email inbox). If I try to change email to an account that exists, I don't get any exceptions/ error messages and the email is not sent, like a silent fail.

The expected result would be to get this error code: "auth/email-already-in-use"

I checked with the Firebase team and they get the correct error code when using plain Java Script.

try {
      // First reauthenticate
      const credential = EmailAuthProvider.credential(
        user.email,
        currentPasswordInput.current?.value
      );
      await reauthenticateWithCredential(auth.currentUser, credential);

      // Then send a verify before update email
      const newEmail = newEmailInput.current.value;
      await verifyBeforeUpdateEmail(auth.currentUser, newEmail);

    } catch (error: any) {
      logError("Update email error:", error);

      if (error.code === "auth/wrong-password") {
        setError("The current password is incorrect");
      } else if (error.code === "auth/invalid-credential") {
        setError("The current password is incorrect");
      } else if (error.code === "auth/email-already-in-use") {
        setError("This email is already in use by another account");
      } else if (error.code === "auth/invalid-email") {
        // Set field-specific error for email
        setFieldErrors({ newEmail: "The email address is not valid" });
      } else {
        // General error for other cases
        setError("Failed to update email. Please try again.");
      }
    }

Project Files

Javascript

Click To Expand

package.json:

    "@react-native-firebase/app": "^23.4.1",
    "@react-native-firebase/auth": "^23.4.1",
    "@react-native-firebase/crashlytics": "^23.4.1",

firebase.json for react-native-firebase v6:

# N/A

iOS

Click To Expand

ios/Podfile:

  • I'm not using Pods
  • [] I'm using Pods and my Podfile looks like:
# N/A

AppDelegate.m:

// N/A


Android

Click To Expand

Have you converted to AndroidX?

  • my application is an AndroidX application?
  • I am using android/gradle.settings jetifier=true for Android compatibility?
  • I am using the NPM package jetifier for react-native compatibility?

android/build.gradle:

// N/A

android/app/build.gradle:

// N/A

android/settings.gradle:

// N/A

MainApplication.java:

// N/A

AndroidManifest.xml:

<!-- N/A -->


Environment

Click To Expand

react-native info output:

Expo app, no react-native CLI
"expo": "~53.0.23"
"react-native": "0.79.5"
  • Platform that you're experiencing the issue on:
    • [] iOS
    • Android
    • iOS but have not tested behavior on Android
    • Android but have not tested behavior on iOS
    • Both
  • react-native-firebase version you're using that has this issue:
    • 23.4.1
  • Firebase module(s) you're using that has the issue:
    • Authentication
  • Are you using TypeScript?
    • Y & 5.8.3

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions