Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/luiss811/Backend-Airguide/llms.txt

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

New accounts are not immediately active. After a successful registration the account estado is set to pendiente, and an administrator must approve it before the user can complete the login flow. This page also documents GET /api/auth/me, which returns the profile of the currently authenticated user.

POST /api/auth/register

Creates a new user record with the alumno role. Both correo and matricula must be unique across all existing accounts.

Request body

correo
string
required
Email address for the new account. Must not already be registered.
password
string
required
Password for the account. Stored as a bcrypt hash; never persisted in plain text.
nombre
string
required
Full name of the user.
matricula
string
Student ID number. Optional, but must be unique if provided. Defaults to an empty string when omitted.

Response — 201 Created

message
string
Confirmation string: "Registro exitoso. Tu cuenta está pendiente de validación por un administrador."
usuario
object
The newly created user record.

Error responses

StatusBodyCause
400{ "error": "El correo ya está registrado" }An account with the same correo already exists.
400{ "error": "La matrícula ya está registrada" }An account with the same matricula already exists.
400{ "error": "<validation message>" }Zod schema validation failed (e.g. missing required field).
After registration, the user cannot log in until an administrator changes the account estado to activo using PUT /api/auth/validate/:id. Direct the user to contact their institution’s administrator to request approval.

Example

curl --request POST \
  --url https://api.example.com/api/auth/register \
  --header 'Content-Type: application/json' \
  --data '{
    "correo": "nuevo@ejemplo.edu.mx",
    "password": "s3cur3P@ss",
    "nombre": "María López",
    "matricula": "A00198765"
  }'
{
  "message": "Registro exitoso. Tu cuenta está pendiente de validación por un administrador.",
  "usuario": {
    "id": 87,
    "correo": "nuevo@ejemplo.edu.mx",
    "nombre": "María López",
    "matricula": "A00198765",
    "rol": "alumno",
    "estado": "pendiente"
  }
}

GET /api/auth/me

Returns the full profile of the currently authenticated user. Use this endpoint to retrieve up-to-date account details after login or to verify the token is still valid. Authentication required: Authorization: Bearer <token>

Response — 200 OK

id_usuario
number
Internal numeric user identifier.
correo
string
User’s registered email address.
nombre
string
User’s full name.
matricula
string
Student ID number, or empty string if not set.
rol
string
Role assigned to the account: rector, admin, profesor, or alumno.
estado
string
Current account status: activo, pendiente, or rechazado.
fecha_registro
string
ISO 8601 timestamp of when the account was created.
fecha_validacion
string
ISO 8601 timestamp of when the account was last validated by an administrator. May be null if not yet validated.

Example

curl --request GET \
  --url https://api.example.com/api/auth/me \
  --header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'
{
  "id_usuario": 42,
  "correo": "alumno@ejemplo.edu.mx",
  "nombre": "Juan Pérez",
  "matricula": "A00123456",
  "rol": "alumno",
  "estado": "activo",
  "fecha_registro": "2024-08-15T10:30:00.000Z",
  "fecha_validacion": "2024-08-16T09:00:00.000Z"
}

Build docs developers (and LLMs) love