TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/vanegasjoseignacio2-cyber/Eco-It/llms.txt
Use this file to discover all available pages before exploring further.
/api/user router exposes endpoints for authenticated users to manage their own profile, change their password, and permanently delete their account. It also hosts a public endpoint that serves recycling collection point data for the interactive map, and a mirror of the password-recovery flow for convenience on the client side.
All protected endpoints require an
Authorization: Bearer <token> header. Tokens are issued by the auth endpoints and expire in 12 hours (login) or 7 days (registration verification).Profile endpoints
GET /api/user/perfil
Returns the full profile of the currently authenticated user. The password field is never included in the response (select: false at the model level).
Authentication: Required.
Response
true on success.User profile object.
MongoDB
_id.First name.
Last name.
Email address (lowercase).
Phone number.
Age.
URL of the user’s avatar image, or empty string if not set.
Role:
"user", "admin", or "superadmin".Account status:
"active", "inactive", or "banned".ISO 8601 date-time until which the account is banned, or
null.Human-readable reason for the ban, or
null.true when all required profile fields have been filled in.ISO 8601 account creation timestamp.
PUT /api/user/perfil
Updates one or more profile fields for the authenticated user. Only the fields included in the request body are modified — omitted fields are left unchanged.
Authentication: Required.
Request body — all fields are optional; include only those to update.
New first name.
New last name.
New phone number.
New age.
URL pointing to the user’s new avatar image (e.g., a Cloudinary URL obtained after a separate upload).
"Perfil actualizado exitosamente".Updated user data:
id, nombre, apellido, email, telefono, edad, avatar.DELETE /api/user/perfil
Permanently deletes the authenticated user’s account. This action is irreversible. An audit log entry is created automatically.
Authentication: Required.
Request body: None.
Response
"Cuenta eliminada exitosamente".Password change
PUT /api/user/cambiar-password
Allows an authenticated user to change their own password by supplying the current password for verification. The new password is hashed automatically by the Mongoose pre('save') hook.
Authentication: Required.
This endpoint is for authenticated users who know their current password. For unauthenticated password recovery via email code, use the
/api/auth/recuperar-password flow or the recovery mirror routes documented below.The user’s current (existing) password in plain text.
The desired new password. Minimum 8 characters (enforced by the controller before saving).
"Contraseña cambiada exitosamente" on success.| Condition | Status | Message |
|---|---|---|
passwordActual or passwordNueva missing | 400 | "Debes proporcionar la contraseña actual y la nueva" |
| New password fewer than 8 characters | 400 | "La nueva contraseña debe tener al menos 8 caracteres" |
| Current password incorrect | 401 | "La contraseña actual es incorrecta" |
| User not found | 404 | "Usuario no encontrado" |
Public map points
GET /api/user/map-points
Returns all recycling collection points that are both activo: true and visibleToUser: true. This is the data source for the Eco-It interactive Leaflet map displayed to regular users.
Authentication: Not required (public endpoint).
Response
Array of processed point objects, sorted newest first.
MongoDB
_id of the point.Display name of the collection point.
Point category. One of:
"recycling", "ecobottle", "truck", "container", "green_zone".Latitude coordinate.
Longitude coordinate.
Cloudinary URL of the point’s photo, or empty string.
Short description of the collection point.
The same data is also available at
GET /api/map/points via a dedicated map router. Both endpoints query identical data from the PuntoReciclaje collection. See the Map Endpoints page for full schema documentation.Password recovery mirror routes
The following recovery routes are mounted on/api/user for client-side convenience. They call the same controller functions as their /api/auth counterparts and behave identically. Refer to the Auth Endpoints page for complete documentation.
| Method | Path | Description |
|---|---|---|
POST | /api/user/recuperar-password | Send a 6-digit recovery code to the user’s email. |
POST | /api/user/verificar-codigo | Verify the recovery code (pre-reset validation step). |
POST | /api/user/reenviar-codigo | Resend the recovery code (3-minute cooldown). |
POST | /api/user/restablecer-password | Set a new password using a valid code. |
These routes are public (no JWT required) because the user cannot authenticate when they have forgotten their password.
Error reference
| HTTP Status | Cause |
|---|---|
400 | Validation error (missing fields, password too short) |
401 | Missing or invalid JWT; incorrect current password |
404 | Authenticated user’s record not found in the database |
500 | Internal server error |