Skip to main content
The update_user.js module provides two functions for modifying user credentials: update_email and update_password. Both update Firebase Authentication directly using the Admin SDK.

Functions overview

FunctionWhat it updates
update_emailFirebase Auth email + Firestore email field + date.last_update
update_passwordFirebase Auth password only

update_email

Updates a user’s email address in Firebase Authentication and then updates the matching document in the specified Firestore collection.

Endpoint

POST https://<region>-<project>.cloudfunctions.net/update_email

Request

data.uid
string
required
The Firebase Authentication UID of the user whose email is being updated.
data.email
string
required
The new email address to set.
data.emailold
string
required
The user’s current (old) email address. Used to locate the Firestore document to update.
data.collection
string
required
The Firestore collection containing the user’s document. One of u_clients, u_collaborators, or u_staff.
{
  "data": {
    "uid": "abc123xyz",
    "email": "[email protected]",
    "emailold": "[email protected]",
    "collection": "u_clients"
  }
}

What it does

  1. Calls auth.updateUser(uid, { email }) to update the email in Firebase Authentication.
  2. Queries {collection} for documents where email == emailold.
  3. For each matching document, updates:
    • email → the new email address
    • date.last_updateTimestamp.now()

Response

Success (200):
message
string
"Usuario: Email Actualizado!"
status
number
200
data
object
{
  "message": "Usuario: Email Actualizado!",
  "status": 200,
  "data": { "update": true }
}
Error (400):
message
string
"Usuario: Email No Actualizado!!"
status
number
400
data
object
{
  "message": "Usuario: Email No Actualizado!!",
  "status": 400,
  "data": {
    "update": false,
    "error": {
      "code": "auth/email-already-exists",
      "message": "The email address is already in use by another account."
    }
  }
}
If the Firebase Authentication update fails, the Firestore document is not modified. If the Auth update succeeds but the Firestore update fails, the function still returns 200 — ensure your application handles this potential inconsistency.

update_password

Updates a user’s password in Firebase Authentication.

Endpoint

POST https://<region>-<project>.cloudfunctions.net/update_password

Response

Success (200):
{
  "message": "Usuario: Password Actualizado!",
  "status": 200,
  "data": { "update": true }
}
Error (400):
{
  "message": "Usuario: Password No Actualizado!!",
  "status": 400,
  "data": {
    "update": false,
    "error": {}
  }
}
The update_password function updates Firebase Authentication only. No Firestore fields are modified when changing a password.

Build docs developers (and LLMs) love