/api/auth/login
Validates a Cloudflare Turnstile token, checks the user’s credentials, and returns a signed JWT on success.
Request body
Username of the account to authenticate.
Plain-text password. Compared against the bcrypt hash stored in the database.
Cloudflare Turnstile token obtained from the client-side widget. Verified against the Turnstile
/siteverify endpoint before any credential check.Response
true on a successful login.Signed JWT. Expires in 8 hours. The payload contains
id, idPerfil, and nombre.Error responses
| Status | Message | Cause |
|---|---|---|
400 | Fallo en la validación del captcha. | Turnstile verification returned success: false. |
401 | El usuario no existe o su estado es inactivo. | No user found with that username, or idEstadoUsuario is false. |
401 | Usuario o contraseña incorrectos. | Password does not match the stored bcrypt hash. |
Store the returned token in an
auth_token cookie with maxAge set to 8 hours (28800 seconds) to match the JWT expiry.Examples
Success response
200