skip to Main Content

I am looking to update the firebase email in the authentication. Once I update the email, and if I check back the Firebase Authentication, I am hoping to see the new email. Next time when I try to login, then I can login with the new email, but can use the old password. Is it possible (if at all)?

2

Answers


  1. You can use the Firebase Admin SDK to modify an existing user’s data, including it’s email, see the documentation.

    So, with the user uid and the new email you would do as follows:

    admin
      .auth()
      .updateUser(uid, {
        email: '[email protected]'
      })
      .then((userRecord) => {
        // See the UserRecord reference doc for the contents of userRecord.
        console.log('Successfully updated user', userRecord.toJSON());
      })
      .catch((error) => {
        console.log('Error updating user:', error);
      });
    

    The above code is Node.js code that you can, for example, run in a Cloud Function or even as a Node.js script from you computer (See the section names "For Firestore" of this SO answer for an example).

    Login or Signup to reply.
  2. Renaud’s answer shows how you can change the email address for any user in a trusted environment.

    If you want the user themselves to be able to change their email address from the Flutter app, you can use verifyBeforeUpdateEmail for that.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search