Skip to content

Fix/cart security routes#55

Merged
Marcos203403 merged 2 commits into
developfrom
fix/cart-security-routes
May 16, 2026
Merged

Fix/cart security routes#55
Marcos203403 merged 2 commits into
developfrom
fix/cart-security-routes

Conversation

@Marcos203403
Copy link
Copy Markdown
Contributor

This pull request updates the carrito (shopping cart) endpoints to improve security and user experience by enforcing authentication and ensuring that cart operations are always performed for the authenticated user, rather than relying on client-supplied IDs. The main changes include requiring a valid token for all carrito routes and extracting the user ID from the authenticated token in controller logic.

Authentication and Authorization Improvements:

  • All carrito routes now require authentication via the verificarToken middleware, ensuring only logged-in users can access or modify their cart. (src/routes/carritoRoutes.js, src/routes/carritoRoutes.jsR5-R11)
  • Controller functions (getCarrito, agregarAlCarrito, vaciarCarrito) now extract the user ID from the authenticated req.usuario.id instead of accepting it from request parameters or body, preventing unauthorized access to other users' carts. (src/controllers/carritoController.js, [1] [2]

API Endpoint Adjustments:

  • Route parameters for user IDs have been removed from the API endpoints, simplifying the API and reducing the risk of misuse (e.g., /carrito instead of /carrito/:idCliente). (src/routes/carritoRoutes.js, src/routes/carritoRoutes.jsR5-R11)

These changes enhance the security and integrity of the carrito functionality by tying all cart operations directly to the authenticated user.

@Marcos203403 Marcos203403 added the enhancement New feature or request label May 16, 2026
Copy link
Copy Markdown
Contributor

@inmaculadaprisca inmaculadaprisca left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JWT middleware is properly implemented on the cart routes now. Tested and working

@Marcos203403 Marcos203403 merged commit e5c0fd9 into develop May 16, 2026
1 check passed
@Marcos203403 Marcos203403 deleted the fix/cart-security-routes branch May 16, 2026 21:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants