UniEvents enforces a role-based access control (RBAC) model using aDocumentation 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.
role field stored directly on every user record and encoded inside the session JWT. When a user authenticates, their role is embedded in a signed cookie and validated server-side on every protected route and API handler via getSession(). There are five distinct roles, ranging from a platform-wide superadmin to the end-user attendee who simply registers for events.
The Five Roles
superadmin
Full system access. Manages universities, tenants, categories, global users, and system settings. Accesses the dedicated
/admin portal. tenantId is null for superadmins — they are not scoped to any single faculty.tenant_admin
Manages everything within their assigned faculty: events, spaces, users, and payment verification. Approves or rejects events submitted by event managers. Views faculty metrics and analytics. Accesses
/faculty-admin.event_manager
Creates and edits events on behalf of a faculty. Newly created events are submitted with
status = 'pendiente' and must be approved by a tenant_admin before they go public. Can view attendee lists for their events. Accesses /faculty-admin.access_control
Scans QR-coded tickets at event entry points. Has access only to the scanner interface at
/faculty-admin/scanner. Cannot create events or view payment data.user
A public attendee. Registers for events, uploads payment proofs for paid events, and views their own tickets (with QR codes) from their profile. Cannot access any admin portal.
Role vs. Capability Matrix
| Capability | superadmin | tenant_admin | event_manager | access_control | user |
|---|---|---|---|---|---|
| Manage universities & categories | ✅ | — | — | — | — |
| Create / delete tenants | ✅ | — | — | — | — |
| Manage global users | ✅ | — | — | — | — |
| Manage tenant spaces | ✅ | ✅ | — | — | — |
| Create events (auto-approved) | ✅ | ✅ | — | — | — |
| Create events (pending approval) | — | — | ✅ | — | — |
| Approve / reject events | ✅ | ✅ | — | — | — |
| View attendees for an event | ✅ | ✅ | ✅ | — | — |
| Verify / reject payment proofs | — | ✅ | — | — | — |
| Scan QR tickets | ✅ | ✅ | ✅ | ✅ | — |
| Register for events | — | — | — | — | ✅ |
| Upload payment proofs | — | — | — | — | ✅ |
| View own tickets | — | — | — | — | ✅ |
Role Field in the Schema
Therole field is a plain varchar column on the users table. It defaults to 'user' so newly registered accounts are always attendees unless explicitly promoted.
tenantId is nullable. A superadmin has tenantId = null because their authority spans all tenants. Every other staff role (tenant_admin, event_manager, access_control) must have a tenantId that ties them to a specific faculty.The organizerLevel Enum
In addition to their role, users who organize or manage events carry an organizerLevel attribute. This enum classifies the seniority or affiliation of the organizer:
| Value | Meaning |
|---|---|
academico | University-affiliated academic organizer (default) |
amateur | Non-affiliated or student-run organizer |
registrado | Basic registered organizer with no special affiliation |
Protecting Routes with getSession()
Every server component, API route handler, and server action that requires authentication calls getSession(). This function reads the session cookie, verifies the HS256-signed JWT, and returns the decoded payload — or null if the session is missing or expired.
tenant_admin, event_manager, superadmin, and access_control):
Session JWT Payload
When a user logs in,createSession() signs a JWT containing the following fields and stores it as an httpOnly cookie named session. The token expires after 7 days.
| JWT Field | Type | Description |
|---|---|---|
userId | string (UUID) | The authenticated user’s ID |
role | string | One of the five role values |
tenantId | string | null | The faculty this user belongs to (null for superadmin) |
email | string | The user’s verified email address |
expiresAt | Date | Expiry timestamp (7 days from login) |