XHealtXperience enforces access control through Spatie Laravel Permission, a battle-tested RBAC package for Laravel. Every user in the system carries exactly one role, and that role determines which routes, UI sections, and data they can reach. Roles are scoped per-tenant — aDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/Arthurr23/XHealtXperience/llms.txt
Use this file to discover all available pages before exploring further.
Doctor in one clinic has no visibility into another clinic’s data whatsoever, because each tenant runs on its own isolated database.
Role Overview
The platform ships with eight roles. Seven are tenant-level roles that live in each clinic’s database; Super Admin is the sole central role that lives in the shared central database and is never assignable by a clinic administrator.Super Admin
Central database only. Manages the multi-tenant platform itself: creates/suspends clinics, sets per-clinic user limits, and manages global administrators.
Administrador Clinica
Full clinic administrator. Manages users, patients, appointments, services, surgical suites, settings, and can view the audit log.
Doctor
Manages their own agenda, blocks time slots, schedules and edits surgeries, and views patients and services within their clinic.
Recepcion
Manages patients and appointments, performs check-in, and views services. No access to administrative settings.
Enfermero
Read-only access to patients and the surgical suite view. Cannot create or modify records.
Auditor
Read-only access to the full audit log (bitácora) and a dedicated security dashboard showing suspicious activity metrics.
Paciente
Access to their own dashboard only. Cannot navigate any administrative or clinical area.
Practicante Externo
External trainee with limited access scoped by the clinic administrator on a case-by-case basis.
Role Reference Table
| Role | DB Scope | Key Capabilities |
|---|---|---|
Super Admin | Central DB | Create/suspend tenants, manage global admins, set clinic limits |
Administrador Clinica | Tenant DB | Full user CRUD, patients, appointments, services, surgical suite, settings, audit log |
Administrador Profesionista | Tenant DB | Professional-level admin — scoped subset of clinic administration |
Doctor | Tenant DB | Own agenda, block slots, schedule/edit/cancel surgeries, view patients & services |
Recepcion | Tenant DB | Patients, appointments, check-in, view services, confirm surgical staff |
Enfermero | Tenant DB | View patients, view surgical suite |
Auditor | Tenant DB | Read-only audit log, dedicated auditor dashboard with security metrics |
Paciente | Tenant DB | Own patient dashboard only |
Practicante Externo | Tenant DB | Limited access assigned by clinic administrator |
Checking Roles in Controllers
XHealtXperience uses Spatie’s built-in helpers to authorize actions at the controller layer. TheUserController restricts its entire surface to Administrador Clinica via Laravel’s Middleware class:
HasRoles trait:
Middleware Stack on Routes
Every protected route inroutes/tenant.php is wrapped in a layered middleware stack. The order matters: auth confirms the user is logged in, two_factor confirms the 2FA challenge has been passed, check_inactivity enforces the idle-session timeout, and the role: middleware confirms the user has the required role.
Account Lockout
XHealtXperience protects against brute-force attacks by locking accounts after a configurable number of consecutive failed login attempts. How it works: TheUser model tracks two fields:
| Field | Type | Purpose |
|---|---|---|
failed_login_attempts | integer | Count of consecutive failed logins since last successful login |
is_locked | boolean | Set to true when the attempt count reaches the configured maximum |
max_login_attempts column on the TenantSetting model (default: 3). When a user successfully authenticates, resetFailedAttempts() is called automatically:
Administrador Clinica can unlock a locked account via the dedicated endpoint:
auth.account_unlocked.
Session Inactivity Timeout
Thecheck_inactivity middleware (CheckInactivity) automatically logs out users who have been idle for too long. The timeout duration is read from the inactivity_timeout_minutes column of the TenantSetting model (default: 15 minutes if not configured).
Behavior:
- On every authenticated Inertia/web request, the session key
ultima_actividadis refreshed. - If the time elapsed since the last activity equals or exceeds
inactivity_timeout_minutes, the middleware:- Logs the user out and invalidates the session.
- Regenerates the CSRF token.
- Redirects to
/{tenant}/loginwith a status message.
- For Inertia XHR requests, it returns an HTTP
409response with anX-Inertia-Locationheader pointing to the login page so the browser performs a full page reload.