0

I know how to update the password of signed in user in firebase auth:

var user = firebase.auth().currentUser; //get current connected user
    return user.updatePassword(newPass)
      .then(
        () => //success
      )
      .catch(error => this.handleError(error))
  }

But I don't know how to do the same with a not signed in user. Perhaps retrieve user auth persistance only with his email with kind like that (but there is no way to do that):

var user = firebase.auth().getUserByEmail(email); //not implmented in auth firebase

PS: I don't want to use the method sendPasswordResetEmail()

var auth = firebase.auth();
    return auth.sendPasswordResetEmail(email);

Greatly appreciated help, Thanks !

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807

1 Answers1

0

The client-side Firebase SDKs only allow sending password reset (and other messages) to the currently signed in user, as any other calls would be major abuse vectors. So there is no way to send a password reset message to a user based on their email address alone.

If you want this functionality, you will have to implement it yourself. At the end of the process, you can then use the Firebase Admin SDK to update the password in the user's profile.

Also see:

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
  • If I use Firebase Admin and use this: `admin.auth().updateUser(uid, { password: 'newPassword'` Does the newPassword is taken in Firebase authentification or just in user doc on "firestore database" section or both ? – Dorian Vieira Jun 24 '21 at 15:35
  • The Firebase Authentication SDKs only update the user profile in Firebase Authentication. They don't store any data in the Firebase database products. – Frank van Puffelen Jun 24 '21 at 20:11
  • It's wrong to say client-side SDK only allows a currenlty-logged-in user to send password-reset emails to themselves. In fact, client-side SDK allows sending password-reset emails, while not logged in, to any email that has an account with your app. See client-side JavaScript function sendPasswordResetEmail at https://firebase.google.com/docs/reference/js/auth.md#sendpasswordresetemail – Morris Dec 31 '21 at 01:33
  • Good point Morris. The method wouldn't be all that useful if you had to be signed in to call it on your own profile. :) – Frank van Puffelen Dec 31 '21 at 01:39