Gestor Deportivo uses JSON Web Tokens (JWT) to protect API endpoints. After a user registers, verifies their email, and logs in, they receive a token that must be included with every subsequent request. Tokens are long-lived (365 days) and stored server-side; logging out invalidates them immediately.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/fredy-rizo/gestor-backend/llms.txt
Use this file to discover all available pages before exploring further.
How authentication works
Every protected route passes through theToken middleware, which reads the access-token request header, verifies the JWT signature, and loads the matching user from MongoDB. If any step fails the request is rejected before it reaches the controller.
The header name is
access-token (all lowercase), not Authorization or Bearer. Using the wrong header name will always result in a 403 No hay token response.Registration flow
Create an account
Send a On success the API creates the account with default role
POST request to /api/user/register with the user’s personal details. The endpoint also accepts an optional profile image via multipart/form-data.User’s first name.
User’s last name.
Email address — must be unique. Stored in lowercase.
Plain-text password; hashed before storage.
One of
Masculino, Femenino, or Otro.Usuario (value "1") and default activation status Inactivo (value "2"), then emails a 5-digit verification code to the provided address.Verify the email address
Check the inbox for the verification email and submit the code to activate the account.A successful verification sets the account status to
The email address used during registration.
The 5-digit code from the verification email.
Activo (value "Activo"), allowing the user to log in.Log in
See the Login flow section below to obtain a token.
Login flow
Send credentials to/api/user/login. The API checks that the account is active, validates the password, and returns a signed JWT.
The registered email address.
The account password.
The JWT to include in the
access-token header on all subsequent requests.true when login succeeds.id, firstName, lastName, email, avatar, sex, idTeam, idPlayer, roles, and activate. Tokens expire after 365 days.
Passing the token
Include the token in theaccess-token header on every protected request:
Token expiry
Tokens are valid for 365 days from the moment of login. After expiry the API returns a401 response and the user must log in again to obtain a fresh token.
Logout
Logging out clears the token stored server-side, invalidating it immediately even though the JWT itself has not expired.The email address of the user to log out.
Error responses
| HTTP Status | Message | Cause |
|---|---|---|
403 | No hay token | access-token header is missing from the request |
401 | Token inexistente | Token is present but invalid or malformed |
404 | No hay usuario | Token is valid but the user no longer exists in the database |
Password recovery
If a user forgets their password, a two-step recovery flow resets it via an emailed code.Request a recovery code
Roles
Every user carries aroles array in their JWT payload and MongoDB document. Gestor Deportivo ships with two built-in roles:
Usuario
Default role assigned at registration.
name: "Usuario", value: "1". Subject to membership plan limits (e.g., maximum teams).Admin
Elevated role for platform administrators.
name: "Admin", value: "2". Bypasses all resource limits and can manage other users’ data.