Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Edfermachado/proyectoSistemas/llms.txt

Use this file to discover all available pages before exploring further.

UniEvents includes a browser-based QR code scanner at /faculty-admin/scanner that lets authorized staff verify attendee tickets at event entrances. Each attendee receives a unique ticketToken (UUID) embedded in their QR code. When scanned, the server marks the token as used and writes an immutable scan log record, providing a tamper-resistant audit trail of all entry validations.

Scanner Access

Navigate to /faculty-admin/scanner. The scanner page is accessible to sessions holding one of the following roles:
  • tenant_admin
  • event_manager
  • superadmin
  • access_control
The access_control role is specifically designed for gate staff who only need the scanning capability. Users with this role are automatically redirected to /faculty-admin/scanner on login and cannot navigate to any other section of the portal.

How Scanning Works

1

Start the camera

Click Iniciar Escáner and grant the browser camera permission when prompted. The scanner uses the device’s rear-facing camera (facingMode: "environment") at 10 frames per second with a 250×250 pixel QR detection box.
2

Frame the QR code

Align the attendee’s QR code within the visible scanner frame. The html5-qrcode library decodes the QR code and extracts the ticketToken UUID string.
3

Ticket validation request

The scanner automatically sends a POST request to /api/tickets/validate with the decoded token:
POST /api/tickets/validate
Content-Type: application/json
Cookie: session=<scanner-jwt>

{
  "token": "3f8a1b2c-dead-beef-cafe-0123456789ab"
}
4

Server processes the token

The server looks up the attendees table by ticketToken:
  • Token found, scannedAt is null → Updates scannedAt to the current timestamp, inserts a record in scanLogs (with eventId, attendeeId, and scannedBy from the session), and returns 200 OK with attendee details.
  • Token found, scannedAt is already set → Returns 409 Conflict (ticket already used).
  • Token not found → Returns 404 Not Found.
5

Visual feedback is displayed

The scanner overlay changes color and displays a large status message:
ResultOverlayMessage
Valid, first scan🟢 GreenACCESO PERMITIDO + attendee name and type
Already scanned🟡 GoldTICKET YA ESCANEADO
Not found / error🔴 RedTICKET INVÁLIDO or connection error
After 3.5 seconds, the overlay clears and the scanner resumes listening for the next QR code.

API Reference — Ticket Validation

Request:
POST /api/tickets/validate
Content-Type: application/json

{
  "token": "3f8a1b2c-dead-beef-cafe-0123456789ab"
}
Success response (200 OK):
{
  "success": true,
  "message": "Acceso Permitido (200)",
  "attendee": {
    "name": "María González",
    "type": "estudiante",
    "event": "Workshop de Diseño UX"
  }
}
Ticket already used (409 Conflict):
{
  "error": "Entrada ya utilizada (409)",
  "scannedAt": "2025-09-15T11:42:00.000Z"
}
Token not found (404 Not Found):
{
  "error": "Entrada no encontrada (404)"
}
Each ticketToken is single-use. Once a ticket has been scanned and scannedAt is set, any subsequent attempt to scan the same token returns a 409 Conflict error — even if the scan happens milliseconds later. This prevents ticket sharing and duplicate entry. The token cannot be reset through the scanner interface.

Scan Logs

Every successful scan is recorded in the scanLogs table with the following fields:
FieldDescription
eventIdThe event the scanned attendee is registered for.
attendeeIdThe specific attendee record that was validated.
scannedByThe userId of the logged-in staff member who performed the scan.
scannedAtTimestamp of when the scan occurred (set automatically).
Scan logs are immutable — they cannot be deleted through the UI. They are visible to tenant_admin users on the Audit Logs page (/faculty-admin/audit), which shows the 100 most recent scans across all of the faculty’s events, ordered by scannedAt descending.

HTML5 QR Code Library

The scanner is built on the html5-qrcode library, which provides cross-browser camera access and QR decoding via the browser’s MediaDevices API. The scanner instance is attached to a <div id="reader"> element in the DOM. The library is initialized on component mount and properly stopped and cleaned up when the component unmounts or the user clicks Detener Escáner.

Build docs developers (and LLMs) love