TMT uses a PIN-based access system for physical ticket offices (taquillas). The office_validate function checks a collaborator’s PIN before granting them access to sell tickets, while office_pin_set lets administrators set or update an office PIN.
Firestore structure
Offices are stored under the offices collection:
offices/
{office_id}/
collaborators/
{collaborator_id} # must have status: true
security/
access_pin # { pin: "...", date: { created, updated } }
office_validate
Validates a collaborator’s PIN for a specific office. The function checks:
- That the collaborator is associated with the office (
collaborators/{idcollaborators} exists)
- That the collaborator’s
status is true
- That the supplied
pin matches the PIN stored in offices/{idoffice}/security
On success, it updates the date.updated timestamp on the security/access_pin document.
Endpoint
POST https://{region}-{project}.cloudfunctions.net/office_validate
Request
The Firestore document ID of the office.
The collaborator document ID within offices/{idoffice}/collaborators.
The PIN to validate against the office security document.
{
"data": {
"idoffice": "office_xyz",
"idcollaborators": "collab_abc",
"pin": "1234"
}
}
Response
Validation passed:
{
"message": "Oficce allowed",
"status": 200,
"data": { "valido": true }
}
Wrong PIN:
{
"message": "Oficce not allowed",
"status": 400,
"data": { "valido": false }
}
Collaborator not active:
{
"message": "Usuario no activo en la taquilla",
"status": 400,
"data": { "valido": false }
}
Collaborator not associated with office:
{
"message": "Usuario no asociado con la taquilla",
"status": 400,
"data": { "valido": false }
}
office_pin_set
Sets or overwrites the PIN for a ticket office. Writes to offices/{idoffice}/security/access_pin with the new PIN and current timestamps.
Endpoint
POST https://{region}-{project}.cloudfunctions.net/office_pin_set
Request
The Firestore document ID of the office.
The new PIN to set for the office.
{
"data": {
"idoffice": "office_xyz",
"pin": "5678"
}
}
Response
Success:
{
"message": "Office: Pin Seteado!",
"status": 200,
"data": { "valido": true }
}
Error:
{
"message": "Office: Error al crear",
"status": 400,
"data": { "valido": false }
}
Only administrators should call office_pin_set. After setting the PIN, collaborators use office_validate with their collaborator ID and the new PIN to gain access to the office interface.