Authentication
This endpoint requires authentication. Include a valid JWT token in the Authorization header.
This action is permanent and cannot be undone. All user data will be removed from the database.
Request Body
curl --location 'http://localhost:8080/secured/delete_user' \
--header 'Content-Type: application/json' \
--header 'Authorization: YOUR_JWT_TOKEN' \
--data-raw '{
"id": 5
}'
Response
Success Response (200)
{
"msg": "Usuario eliminado"
}
Error Responses
Returned when the JWT token is invalid or missing{
"msg": "Token_invalido"
}
or{
"msg": "Sin autorización"
}
Implementation Details
The endpoint performs a direct deletion from the usuarios table:
DELETE FROM usuarios WHERE id = ?
Ensure that cascading deletes or foreign key constraints are properly handled if the user has related records in other tables (e.g., bitacora, productos_publicados).
Best Practices
- Confirmation: Always implement a confirmation dialog in your application before calling this endpoint
- Audit Trail: Consider implementing soft deletes or maintaining an audit log of deleted users
- Related Data: Check for related data (activity logs, published products) before deletion
- Permissions: Restrict this endpoint to admin-level users only