0

Could I know how to get User data by Email registered to Firebase Auth?

Because I'm using Firebase auth to create users by createUserWithEmailAndPassword in the system from backend. In that method, I'm avoiding password encryption.

And In the future, If I need to update a user password from the backend I want user data. And I don't save uid in my MongoDB for security reasons.

I read so many articles that say use getUserByEmail I think this is deprecated.

How can I do this? Need help :)

1 Answers1

1

The documentation doesn't say anything about getUserByEmail being deprecated. It literally says:

In some cases you will have a user's email instead of their uid. The Firebase Admin SDK supports looking up user information with an email:

So, you should just use what the documentation says.

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441
  • But I'm getting following error. `Property 'getUserByEmail' does not exist on type 'Auth'.` Below is my import `import { createUserWithEmailAndPassword, updatePassword, fetchSignInMethodsForEmail, getAuth, } from "firebase/auth";` And the code `getAuth() .getUserByEmail(email) .then((response: any) => { console.log(response); }) .catch((error: any) => { console.log(error); });` – Learning Stuff Jan 13 '23 at 15:49
  • That's a different problem than the one you've originally posted here. Please post the new questions separately with your code and steps to reproduce. – Doug Stevenson Jan 13 '23 at 16:01
  • I will point out that getUserByEmail is specific to the Firebase admin SDK and is not available in the web SDK, which you appear to be using (`firebase/auth`). If you are writing backend code, you should always use the Admin SDK and not the web SDK. – Doug Stevenson Jan 13 '23 at 16:02
  • Oh. Now I get it. Thanks for the help. Let me try again :) – Learning Stuff Jan 13 '23 at 16:11