Skip to content

admin.auth().getUserByEmail is case-insensitive against live data, but case-sensitive against emulator data #8344

@djak250

Description

@djak250

[REQUIRED] Environment info

firebase-tools: 13.34.0

Platform: macOs

[REQUIRED] Test case

Environment setup

  1. Start up just the auth emulator and export emulator host
firebase emulators:start --only auth --project demo-project
  1. Create a user in the emulator AND live environment with the same email: email@example.com

fetchUserByEmail.js

const admin = require('firebase-admin');
admin.initializeApp();

(async () => {
  try {
    const matchingCase = 'email@example.com';
    const user = await admin.auth().getUserByEmail(matchingCase);
    console.log(user); // Logs
  } catch (e) {
    console.error(e); // Doesn't Log
  }
  try {
    const nonMatchingCase = 'EmAiL@eXaMpLe.com';
    const user = await admin.auth().getUserByEmail(nonMatchingCase); // Throws auth/user-not-found
    console.log(user); // Doesn't Log
  } catch (e) {
    console.error(e); // Logs user not found error
  }
  await admin.app().delete();
})();

[REQUIRED] Steps to reproduce

  • Run script against emulator:
FIREBASE_AUTH_EMULATOR_HOST=127.0.0.1:9099 \
GCLOUD_PROJECT_ID=demo-project \
node ./fetchUserByEmail.js
  • Run script against live data:
GCLOUD_PROJECT_ID=project-live \
node ./fetchUserByEmail.js

[REQUIRED] Expected behavior

The user is found in both environments, regardless of email casing.

[REQUIRED] Actual behavior

The user is found in the live environment, regardless of email casing.
The user is found in the emulator environment when the casing matches,
but throws an auth/user-not-found error when casing does not match.

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