Skip to main content

Documentation 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.

La Comanda authenticates users through a standard PHP session established at the views/login.php form. Once logged in, the browser holds a PHPSESSID cookie that is validated by middleware/auth.php on every protected request. The two endpoints documented here handle the end of a session (logout) and the recovery flow for forgotten passwords.

POST /public/api/logout.php

Destroys the current PHP session, records the logout event in the sesiones_activas table, and redirects the browser back to the login page. Method: POST Auth: Any authenticated session (session cookie required)

Request

No request body is required. The endpoint reads $_SESSION directly.

Response

This endpoint does not return JSON. On success it renders a minimal HTML page that immediately redirects the browser to views/login.php?logged_out=1 via both <meta http-equiv="refresh"> and window.location.replace().
HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8
The page also calls window.LaComandaSessionSync.notifyLogout() (from public/js/session-sync.js) so that any other open tabs are notified of the logout before the redirect fires.
Because logout renders an HTML redirect page rather than issuing an HTTP Location header directly, calling this endpoint from a non-browser client (e.g. curl) will receive an HTML body with the redirect URL embedded in it — not a 302 status.

Example

curl -X POST http://localhost:8080/public/api/logout.php \
  -H "Cookie: PHPSESSID=<your-session-id>"

POST /public/api/forgotPassword.php

Initiates the password-reset flow for a registered user. If the submitted email address belongs to an active account, a time-limited reset link is emailed to that address via Mailtrap. To prevent email enumeration, the endpoint always returns the same success response regardless of whether the email was found. Method: POST Auth: None — this is a public endpoint, no session required

Request

Send the body as application/x-www-form-urlencoded (standard HTML form encoding).
email
string
required
The email address associated with the user’s account. Must be a valid email format; invalid or empty values are silently treated as not found and the standard success response is returned.

Response

status
string
Always "OK" when the request is processed without a server error.
message
string
A fixed Spanish-language message that is returned regardless of whether the email was found: "Si el correo está registrado, recibirás instrucciones para restablecer tu contraseña."
{
  "status": "OK",
  "message": "Si el correo está registrado, recibirás instrucciones para restablecer tu contraseña."
}
Error responses:
HTTP StatusCondition
405 Method Not AllowedRequest method is not POST
500 Internal Server ErrorDatabase or mailer exception
{ "status": "ERROR", "message": "Método no permitido" }

Rate Limiting

The endpoint enforces two independent token-budget limits before any email is sent:
  • Per-user limit: A maximum of 3 active (unused, non-expired) reset tokens are allowed per user. Submitting a new request while 3 tokens are already live silently returns the standard success message without creating a new token.
  • Global limit: A maximum of 200 active tokens may exist across all users simultaneously. When this ceiling is reached, all new requests are silently dropped.
Exceeding either rate limit does not produce an error response. The API returns the standard success message to prevent timing-based enumeration. Legitimate users who hit the per-user limit should wait for their existing tokens to expire before requesting again.

Token Details

PropertyValue
Token lifetime60 minutes from creation
Token storageSHA-256 hash stored in password_resets.token; the plain token is sent in the email only
Token formatURL-safe base64 (random_bytes(32), +/-_, no padding)
Invalidation on new requestAll previous active tokens for the user are marked usado = 1 before a new one is inserted
The reset link sent in the email points to {APP_URL}/views/resetPassword.php?token={plain_token}. The APP_URL environment variable controls the base URL; it falls back to https://lacomanda-cafeteriatoscana.up.railway.app when not set.

Example

curl -X POST http://localhost:8080/public/api/forgotPassword.php \
  -d 'email=admin@proyecto.com'
Success response (always):
{
  "status": "OK",
  "message": "Si el correo está registrado, recibirás instrucciones para restablecer tu contraseña."
}
Method error (405):
{
  "status": "ERROR",
  "message": "Método no permitido"
}

Build docs developers (and LLMs) love