Admin Password Reset
Overview
Admins can reset any client’s password from the customer tracking portal. This works by deleting the client’s Firebase Auth record — when the client next logs in with their default password (max + referenceId), JIT provisioning automatically recreates their account.
User Flow
- Admin signs in and searches for a customer by ID
- Customer search results show three action buttons:
- Track Single Package — existing
- View All Packages — existing
- Reset Password — new (red button)
- Clicking “Reset Password” opens a confirmation modal showing the default password (e.g.
max2294) - On confirmation, the frontend calls the
deleteAuthUserCloud Function - A success modal displays the client’s login credentials:
- Email address
- Default password
- A Copy Details button copies both fields to clipboard for easy sharing with the client
Technical Implementation
Frontend (customer_tracking_page/index.html)
Modals:
#reset-password-confirm-modal— Confirmation with cancel/confirm#reset-password-success-modal— Success with email, password, and copy button
Functions:
openResetPasswordModal()— Populates default password preview, shows confirm modalconfirmResetPassword()— Resolves auth email (handles duplicate email format), calls Cloud Function, shows successcloseResetPasswordModal()/closeResetSuccessModal()— Close modalscopyResetDetails()— Copies email + password to clipboard
Duplicate email handling:
The system checks if multiple clients share the same email. If so, it uses the email+refId@domain alias format (e.g. tim+7218@kroha.co) when calling the Cloud Function, ensuring only the correct client’s auth record is deleted.
Local cleanup:
On successful reset, the following localStorage keys are cleared for that client:
passwordChanged_{email}— so JIT provisioning forces a new password changeauthEmail_{email}— removes stored auth email mapping
Cloud Function (deleteAuthUser)
Endpoint: POST https://us-central1-max-inventory-scanner-b0b53.cloudfunctions.net/deleteAuthUser
Request:
{ "email": "client@example.com" }
Response:
{ "success": true, "message": "Auth record deleted" }
Behavior:
- Uses Firebase Admin SDK:
admin.auth().getUserByEmail(email)→admin.auth().deleteUser(uid) - Returns success even if no auth record exists (idempotent)
- CORS enabled for cross-origin requests
Source: maxshipping-web-and-cloudfunctions/functions/index.js
Why Delete Instead of Update?
The Firebase client SDK cannot modify another user’s password — only the currently signed-in user can change their own. The Admin SDK can update passwords, but deleting the auth record is simpler and leverages the existing JIT provisioning system: the account is automatically recreated with the default password on next login, and the forced password change flow kicks in as usual.
Date Added
2026-03-31 — Branch: feature/activity-logging-and-setup