The Users module (Documentation Index
Fetch the complete documentation index at: https://mintlify.com/lucavallini/aibar-frontend/llms.txt
Use this file to discover all available pages before exploring further.
/usuarios) is an administration-only area where an administrator can create new system accounts, update existing user details and roles, and deactivate accounts that are no longer needed. Employees with the empleado role cannot navigate to this route — the adminGuard blocks access and redirects them to /viajes. All user data persists in the database even after deactivation, preserving the full audit trail.
Data Models
Usuario
The core interface returned by every read and write operation in the Users module.
nombre_usuario is never set by the frontend. The backend derives it automatically from nombre_completo when the account is created. After creation, the administrator should communicate the generated nombre_usuario and the chosen password to the new employee.UsuarioCreate
Payload sent when creating a new account.
UsuarioUpdate
Partial payload for editing an existing account. All fields are optional; only the fields that are provided are updated.
Roles
The application recognises exactly two roles. Every user account must be assigned one of them.administrador
Full access to all modules including Users and Audit Log. Can create, edit, and deactivate any account (except their own deactivation).
empleado
Restricted to operational modules: Trips, Drivers, Trucks, Fines, and Fuel. Cannot access
/usuarios or /auditoria.UsuariosService API
The service is injected application-wide via providedIn: 'root' and wraps four HTTP calls against the /usuarios endpoint.
listar(pagina, tamanoPagina)
Fetches a paginated list of all users, both active and inactive.
| Parameter | Type | Default | Description |
|---|---|---|---|
pagina | number | 1 | Page number to retrieve |
tamanoPagina | number | 20 | Number of records per page |
GET /usuarios/?pagina=1&tamano_pagina=20
Returns: Observable<RespuestaPaginada<Usuario>>
crear(datos: UsuarioCreate)
Creates a new user account. The backend derives nombre_usuario from nombre_completo and returns the full Usuario object, including the generated username.
HTTP request: POST /usuarios/
Returns: Observable<Usuario>
Validation (enforced in ListaUsuarios):
nombre_completomust not be blankdnimust not be blankpasswordmust be at least 6 characters
If a user with the same
dni already exists, the backend responds with HTTP 400. The component surfaces this as “Ya existe un usuario con ese DNI”.actualizar(id, datos: UsuarioUpdate)
Updates one or more fields on an existing account via a partial PATCH. The password field cannot be changed through this endpoint.
HTTP request: PATCH /usuarios/{id}
Returns: Observable<Usuario>
darDeBaja(id)
Soft-deactivates the user account — it sets activo: false on the backend. The record is not deleted. A deactivated user can no longer log in, but all their history and audit entries are preserved.
HTTP request: DELETE /usuarios/{id}
Returns: Observable<Usuario>
Create Account Form Fields
The Nuevo usuario modal collects the following fields, which map directly toUsuarioCreate:
Full name of the new user (e.g.
"Juan García"). The backend uses this value to auto-generate the nombre_usuario login handle.National identity document number. Must be unique across all user accounts. Used as a secondary identifier throughout the system.
Initial password for the account. Must be at least 6 characters long. The administrator is responsible for communicating this password to the new user after creation.
Role to assign to the new account. Defaults to
empleado in the creation form. Choose administrador only when the new user needs full system access.Usage Example
The following example shows howListaUsuarios creates a new employee account and handles the two most common error cases:
User Table Columns
The/usuarios view renders one row per account with the following columns, sourced directly from the Usuario interface:
| Column | Source field | Notes |
|---|---|---|
| Nombre completo | nombre_completo | Editable via the Edit modal |
| Usuario | nombre_usuario | Read-only; auto-generated by the backend |
| DNI | dni | Editable; must remain unique |
| Rol | rol | Displayed as a coloured badge; editable |
| Estado | activo | Displays Activo or Inactivo |
| Acciones | — | Edit button always visible; Baja button hidden for own account and already-inactive accounts |
Workflow
Open the New User modal
Click + Nuevo usuario in the page header. The form initialises with blank fields and
rol defaulting to empleado.Fill in the required fields
Enter the Nombre completo, DNI, and an initial Contraseña of at least 6 characters. Select the appropriate Rol.
Submit and note the username
Click Crear usuario. On success, the app displays an alert with the auto-generated
nombre_usuario. Share this login handle and the chosen password with the new user.