The Users API lets administrators manage the staff accounts that access La Comanda. Each account is assigned aDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/JAQA20/LaComanda/llms.txt
Use this file to discover all available pages before exploring further.
rol_id that controls which views and API endpoints the user can reach. Passwords are stored exclusively as bcrypt hashes — plain-text credentials are never persisted. All three endpoints require an active session with rol_id = 1 (Admin).
Role Reference
rol_id | Role Name | Access Level |
|---|---|---|
| 1 | Admin | Full access to all endpoints and views |
| 2 | Mesero | Order creation and table management |
| 3 | Cocina | Kitchen queue views and actions |
| 4 | Barista | Barista queue views and actions |
Create User
POST /public/api/nuevoUsuario.php
Creates a new staff account. The password is hashed with PHP’s PASSWORD_DEFAULT algorithm (bcrypt) before storage — the plain-text value is never written to the database. Validation errors are stored in the session so the form page can re-display them without an additional round trip.
Request Parameters
Staff member’s first name.
Staff member’s last name.
Email address. Must be unique across all user accounts and will be used as the login credential.
Account password. Minimum 8 characters.
Password confirmation. Must be identical to
password.Role to assign. Must be one of
1, 2, 3, or 4. See Role Reference above.Responses
| Outcome | Redirect |
|---|---|
| Success | views/admin/usuarios.php?created=1 |
| Validation failure | Back to form; errors in $_SESSION["nuevo_usuario_errors"] |
Example Request
Edit User
POST /public/api/editarUsuario.php
Updates an existing staff account. To leave the password unchanged, omit the password and password2 fields entirely or send empty strings — the endpoint will skip the password update step in that case. If a new password is provided it must be at least 8 characters and match password2.
Request Parameters
ID of the user account to update.
Updated first name.
Updated last name.
Updated email address. Must remain unique.
Updated role assignment (
1–4).New password. Minimum 8 characters. Leave empty to keep the existing password.
New password confirmation. Must match
password when a new password is being set.Responses
| Outcome | Redirect |
|---|---|
| Success | views/admin/usuarios.php?success=usuario_actualizado |
Changing a user’s
rol_id takes effect immediately on their next page load. Their current session retains the old role until they navigate to a new view.Example Request
Delete User
POST /public/api/eliminarUsuario.php
Permanently removes a staff account. Two hard safety rules apply regardless of caller permissions: the root admin account (id = 1) can never be deleted, and no user can delete their own account.
Request Parameters
ID of the user account to delete.
Responses
| Outcome | Redirect |
|---|---|
| Success | views/admin/usuarios.php?deleted=1 |
Attempted deletion of root admin (id=1) | views/admin/usuarios.php?error=root_delete |
| Attempted self-deletion | views/admin/usuarios.php?error=self_delete |
| Invalid or missing ID | views/admin/usuarios.php?error=bad_id |
| Database deletion failure | views/admin/usuarios.php?error=delete_failed |