firebase-admin-node icon indicating copy to clipboard operation
firebase-admin-node copied to clipboard

getUserByEmail should return undefined if a user does not exist.

Open InputNeuron opened this issue 7 years ago • 2 comments

[REQUIRED] Step 2: Describe your environment

  • Operating System version: Ubuntu 19.04
  • Firebase SDK version: 8.2.0
  • Library version: 8.2.0
  • Firebase Product: firestore

[REQUIRED] Step 3: Describe the problem

getUserByEmail('[email protected]')

will throw an error if the user isn't present.

This isn't a failure but is a totally rational situation. There's no way to lookup a user by email and determine if there was a legitimate failure or not.

All these getUserByX functions should also return a null/undefined instead of throwing an error on a missing value.

InputNeuron avatar Jun 24 '19 00:06 InputNeuron

I found a few problems with this issue:

  • I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
  • This issue does not seem to follow the issue template. Make sure you provide all the required information.

google-oss-bot avatar Jun 24 '19 00:06 google-oss-bot

There's no way to lookup a user by email and determine if there was a legitimate failure or not.

You should check the error code for auth/user-not-found. That is how these APIs are meant to be used:

https://github.com/firebase/firebase-admin-node/blob/1086515e34cab653ec4b4fa29c19d96f4600de4b/test/integration/auth.spec.ts#L281-L284

hiranya911 avatar Jun 24 '19 21:06 hiranya911