Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/CristianRR94/springCommunity/llms.txt

Use this file to discover all available pages before exploring further.

The Update User endpoint allows an authenticated user to change their own username. Only the nombre field is acted upon by the server — the password and email values are accepted by UsuarioEntradaDTO but are not processed by this endpoint. However, because @Valid validation is applied and all three fields carry @NotBlank constraints in the DTO, the request body must include nombre, password, and email or the server will respond with 400 Bad Request. Extra fields not declared on the DTO are silently discarded thanks to @JsonIgnoreProperties(ignoreUnknown = true). The new username must be between 6 and 20 characters. Internally, updating nombre also propagates the change to the associated Participante profile via the cambiarNombre() method on the Usuario entity, keeping both records in sync.

Endpoint

PUT /api/usuarios/modificar
Access: A valid JWT access token must be supplied in the Authorization header. Although /api/usuarios/** is listed as permitAll() in the security configuration, the endpoint logic calls AuthDataService to resolve the authenticated user and will fail if no valid principal is present.

Headers

Authorization
string
required
A valid JWT access token obtained from the authentication endpoint. Must follow the Bearer <accessToken> scheme.Example: Bearer eyJhbGciOiJIUzI1NiJ9...

Request body

The request body must be valid JSON. All three fields declared on UsuarioEntradaDTO carry @NotBlank validation constraints and must be present, even though only nombre is used when updating the account.
nombre
string
required
The new username for the authenticated account. Must be between 6 and 20 characters (inclusive). Must be unique — no other registered user may already have this username.
password
string
required
Must be provided to pass DTO validation. Must be at least 8 characters and contain at least one digit. This value is not used to change the account’s password.
email
string
required
Must be provided to pass DTO validation. Must be a valid email address format. This value is not used to change the account’s email.

Example request body

{
  "nombre": "newusername",
  "password": "ignored1",
  "email": "ignored@example.com"
}

Response

Returns the updated user as a UsuarioSalidaDTO object.
nombre
string
The user’s updated username.
email
string
The user’s email address (unchanged by this endpoint).

Example response

{
  "nombre": "newusername",
  "email": "alice@example.com"
}

Error responses

HTTP statusCondition
400 Bad RequestValidation failure — a required field is blank, nombre is fewer than 6 or more than 20 characters, password is fewer than 8 characters or lacks a digit, or email is not a valid address.
404 Not FoundThe authenticated user could not be located in the database.
401 UnauthorizedThe Authorization header is missing, the token has expired, or the token signature is invalid.

Example error response body

{
  "status": 400,
  "mensaje": "size must be between 6 and 20",
  "timestamp": 1717000000000
}
{
  "status": 401,
  "mensaje": "La sesión ha expirado",
  "timestamp": 1717000000000
}

Example request

curl -X PUT https://api.springcommunity.example/api/usuarios/modificar \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiJ9..." \
  -H "Content-Type: application/json" \
  -d '{"nombre": "newusername", "password": "ignored1", "email": "ignored@example.com"}'

This endpoint also updates the associated Participante record’s display name. The cambiarNombre() method on the Usuario entity checks whether a linked participant exists and, if so, sets nombreParticipante to the same value, ensuring both the authentication identity and the community profile stay in sync.

Build docs developers (and LLMs) love