Overview
The Super Admin (superadmin) role is the highest-level administrative role in DentControl. This role is designed for the SaaS platform owner and has unrestricted access to manage all clinics, users, and system-wide configurations.Key Characteristics
Platform-Wide Access
Manage all registered clinics and their users across the entire SaaS platform
No Clinic Association
Super Admins are not tied to a specific clinic (id_clinica is null)
User Management
Create, edit, suspend, and reactivate users for any clinic
System Dashboard
Access to platform-wide metrics and analytics
Accessible Routes
Super Admin routes are protected by thecan:admin-only middleware, which verifies the user’s role is superadmin.
Dashboard
- Total active clinics
- Total active users across all clinics
- Total patients in the system
- Recently registered clinics
app/Http/Controllers/Admin/AdminController.php:12
Clinic Management
View All Clinics
View All Clinics
Route:
GET /clinicasController: ClinicaController@indexPurpose: Lists all registered clinics ordered by most recent firstSource: routes/web.php:22Create New Clinic
Create New Clinic
Route:
POST /clinicasController: ClinicaController@storeValidates:- Clinic name (max 50 chars, alphanumeric)
- RFC (12-13 chars, unique)
- Address details
- Phone (10 digits, unique)
- Optional logo upload (jpeg, png, jpg - max 2MB)
routes/web.php:23Edit Clinic
Edit Clinic
Route:
GET /clinicas/{id}/editController: ClinicaController@editReturns: JSON with clinic data for modal editingSource: routes/web.php:24Update Clinic
Update Clinic
Route:
PUT /clinicas/{id}Controller: ClinicaController@updateFeatures:- Updates clinic information
- Handles logo replacement (deletes old file)
- Validates unique RFC and phone per clinic
routes/web.php:25Toggle Clinic Status
Toggle Clinic Status
Route:
PATCH /clinicas/{id}/toggleController: ClinicaController@toggleStatusPurpose: Activate or deactivate clinics (switches between ‘activo’ and ‘baja’)Impact: When a clinic is set to ‘baja’, all associated users are blocked from logging inSource: routes/web.php:26User Management
View All Users
View All Users
Route:
GET /usuariosController: UsuarioController@indexPurpose: Lists all users with their associated clinic informationSource: routes/web.php:29Create New User
Create New User
Route:
POST /usuariosController: UsuarioController@storeValidates:- Clinic assignment (must be an active clinic)
- Name, paternal surname (min 3 chars, letters only)
- Username (4-20 alphanumeric, unique)
- Password (min 8 chars, mixed case, numbers)
- Role (dentista or asistente)
- Professional license (required for dentistas, 7-10 digits)
routes/web.php:30Edit User
Edit User
Route:
GET /usuarios/{id}/editController: UsuarioController@editReturns: JSON with user data for modal editingSource: routes/web.php:31Update User
Update User
Route:
PUT /usuarios/{id}Controller: UsuarioController@updateProtection: Superadmin users cannot have their role changed (forced to remain ‘superadmin’)Source: routes/web.php:32Toggle User Status
Toggle User Status
Route:
PATCH /usuarios/{id}/toggleController: UsuarioController@toggleStatusPurpose: Suspend or reactivate users (switches between ‘activo’ and ‘baja’)Protection: Cannot suspend other superadmin usersSource: routes/web.php:33Permission Boundaries
Super Admins are restricted from:
- Accessing clinic-specific routes (
/dentista/*,/asistente/*) - Logging in if their account status is not ‘activo’
- Being edited or suspended by other users
Authentication & Authorization
Gate Definition
Theadmin-only gate is defined in AppServiceProvider.php:26:
Login Redirection
After successful authentication, Super Admins are redirected to:AuthController.php:65
Database Schema
Super Admin users are stored in theusuario table with these distinguishing characteristics:
| Field | Value |
|---|---|
rol | 'superadmin' |
id_clinica | NULL (not associated with any specific clinic) |
estatus | 'activo' (required for login) |
cedula_profesional | NULL (not required) |
Security Considerations
Session Management
Super Admin sessions are subject to the same authentication rules:
- Account must have
estatus = 'activo' - Session regeneration on login for security
- Proper logout and token invalidation
Best Practices
- Limit Super Admin Accounts: Only create Super Admin accounts for trusted platform administrators
- Monitor Activity: Regularly audit Super Admin actions, especially clinic and user modifications
- Strong Passwords: Enforce the system’s password requirements (min 8 chars, mixed case, numbers)
- Clinic Status: Use clinic deactivation (
toggle status) instead of deleting clinics to preserve data integrity - User Suspension: Suspend users rather than deleting them to maintain audit trails
Related Documentation
- Dentist Role - Clinic-level management
- Assistant Role - Reception and scheduling
- Authentication - Login and session management
- Clinic Management - Detailed clinic operations