validate_user.js module exports four functions for user verification across the TMT Platform. Use these after a user authenticates to confirm they have the correct access level before allowing them into protected areas.
Functions overview
| Function | Transport | Purpose |
|---|---|---|
validate_user_platform | HTTP (onRequest) | Check that an email exists in a specific collection |
validate_user_type | HTTP (onRequest) | Check that an email exists with a specific account_type |
setSessionId | Callable (onCall) | Store a session ID in Firestore and as a custom claim |
validate_user_email | HTTP (onRequest) | Confirm a collaborator’s email and activate their account |
validate_user_platform
Checks whether a user with a given email exists in a platform collection.
Endpoint
Request body
Firestore collection to search in. One of
u_clients, u_collaborators, or u_staff.Email address to look up.
Example
Response
User found (200):The function queries the collection for any document where
email equals the provided value. If the snapshot is empty, it returns valido: false.validate_user_type
Checks whether a user with a given email exists in a collection and has a specific account_type.
Endpoint
Request body
Firestore collection to search in.
Email address to look up.
The
account_type value the user must have (for example, admin, collaborator).Example
Response
User found with matching type (200):setSessionId
Stores a session ID for an authenticated user in Firestore (users/{uid}) and sets it as a Firebase custom claim. Use this to enforce single-session policies.
This function uses the Firebase Callable SDK (
onCall), not a plain HTTP request. Call it from a Firebase client SDK, not with a raw HTTP client.Callable invocation (JavaScript)
Request data
A unique identifier for the current session. Generate this on the client after the user signs in.
What it does
- Verifies the caller is authenticated via Firebase Auth. Throws
unauthenticatedif not. - Writes
{ sessionId }tousers/{uid}in Firestore (merges with existing data). - Sets
{ sessionId }as a custom claim on the Firebase Auth user.
Response
validate_user_email
Verifies that a collaborator’s email matches the stored record and, if it matches, sets status to true. Use this as the final step in a collaborator email confirmation flow.
Endpoint
Request body
The UID of the collaborator document in
u_collaborators.The email address to verify against the stored record.
Example
Response
Description of the outcome.
HTTP status code reflecting the outcome.
This function only operates on the
u_collaborators collection. It does not validate clients or staff accounts.