NuestraVoz — Campus Virtual enforces a role-based access control (RBAC) model across every API route and dashboard view. When a user registers or is created by an administrator, aDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/Renzo717/Aula-Virtual-Universidad-Radiolocucion/llms.txt
Use this file to discover all available pages before exploring further.
UserRole is stored in the profiles table. Every subsequent request carries a signed JWT cookie that the server verifies before checking whether the caller’s role is authorised to proceed. Understanding what each role can and cannot do is essential for both platform operators and integrators building on top of the API.
Roles at a Glance
There are four roles in the system, each matching a value of the sharedUserRole type:
Admin
Full platform management: users, careers, subjects, enrolments, grade book, and audit logs. The only role that can delete records or approve pending docente accounts.
Docente (Teacher)
Manages their own assigned subjects only. Creates activities, grades submissions, posts forum threads, and enters final grades. Account requires admin approval before first login.
Estudiante (Student)
Accesses enrolled subjects, submits assignments, participates in forums, and views their grade history and bulletin PDF. Account is immediately active after registration.
Preceptor
Administrative role focused on enrolment management and grade-book operations. Can assign students to careers or subjects, update subject metadata, and enter final grades for any subject.
Account Status
Every profile also carries aUserStatus that gates platform access independently from role:
| Status | Meaning |
|---|---|
activo | Account is fully operational. User can log in normally. |
pendiente | Account exists but is awaiting approval. Login is blocked with a 403 response. Automatically assigned to new docente self-registrations. |
inactivo | Account has been deactivated by an admin. requireAuth rejects every request with 403. |
Only estudiante accounts self-register as
activo. All docente self-registrations start as pendiente and must be explicitly approved by an admin via PATCH /api/users/:id with { "status": "activo" }. The preceptor and admin roles cannot be self-registered — they must be created directly by an admin.How the requireRole Middleware Works
Authentication and authorisation are split into two composable Express middleware functions defined in apps/api/src/middleware/auth.ts.
Step 1 — requireAuth
requireAuth reads the session token from an httpOnly cookie, verifies it with Supabase Auth, fetches the matching profiles row, and rejects inactive accounts. On success it attaches req.user — containing id, email, rol, and status — so downstream middleware can use it without a second database round-trip.
Step 2 — requireRole
requireRole is a factory that accepts one or more UserRole values and returns a middleware function. It reads req.user.rol (set by requireAuth) and returns 403 Sin permisos if the caller’s role is not in the allowed list.
Routes combine the two:
Role Capability Comparison
| Capability | Admin | Docente | Estudiante | Preceptor |
|---|---|---|---|---|
| Create / edit / delete users | ✅ | ❌ | ❌ | ❌ |
| Approve pending docente accounts | ✅ | ❌ | ❌ | ❌ |
| Create / delete careers | ✅ | ❌ | ❌ | ❌ |
| Create subjects | ✅ | ❌ | ❌ | ❌ |
| Edit subject metadata (name, teacher, schedule) | ✅ | ❌ | ❌ | ✅ |
| Manage enrolments (inscripciones) | ✅ | ❌ | ❌ | ✅ |
| Access assigned subjects only | — | ✅ | ❌ | — |
| Access enrolled subjects | — | — | ✅ | — |
| Create activities & grade submissions | ✅ | ✅ | ❌ | ❌ |
| Enter final grades | ✅ | ✅ (own subjects) | ❌ | ✅ (any subject) |
| Download grade bulletins | ✅ | ❌ | ✅ (own) | ✅ |
| View audit log / dashboard stats | ✅ | ❌ | ❌ | ❌ |
| Forum participation | ✅ | ✅ | ✅ | ✅ |
| Update own profile & password | ✅ | ✅ | ✅ | ✅ |
Related Pages
Admin Role
Full platform management, dashboard stats, audit log, and user approval workflow.
Teacher Role
Pending approval flow, subject management, activity grading, and final grade entry.
Student Role
Enrolment model, activity submissions, forum participation, and bulletin download.
Preceptor Role
Enrolment administration, subject editing, and grade-book management.