Debuta uses JSON Web Tokens (JWT) for stateless authentication. After a successful login, the server issues anDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/desarrolladorandres2026-gif/Native-tailwind/llms.txt
Use this file to discover all available pages before exploring further.
access_token that the client includes in subsequent requests as a Bearer token. The same token is also used to authenticate Socket.io connections. Role-based access control is layered on top with two additional middleware guards — soloAdmin and soloAsociado.
User Roles
Every user document in MongoDB has arol field with one of three possible values:
| Role | Value | Description |
|---|---|---|
| Regular user | user | Default role assigned on registration. Access to standard dating app features. |
| Admin | admin | Full access to the admin panel and all /api/admin endpoints. |
| Restaurant partner | asociado | Access to /api/asociado endpoints for managing a restaurant listing. |
JWT Flow
Submit credentials
The client sends a
POST request to /api/login with the user’s email address and password:Receive the access token
On success the server responds with an The token payload contains only
access_token and the serialised user object:{ id } — the MongoDB _id of the user. It is signed with JWT_SECRET and expires after the duration set in JWT_EXPIRES_IN (default 7d).Admin Login
Administrators authenticate through a separate endpoint:{ access_token, usuario } shape as the regular login endpoint. The returned token carries an admin role in the user document that soloAdmin checks at runtime.
Social Auth (Google / Facebook)
Google and Facebook OAuth flows are handled under/api/auth. Regardless of the provider, a successful social login returns the same token structure as password-based login:
A user who registered via Google or Facebook cannot use
POST /api/login with a password. The server detects the auth_provider field on the user document and returns a 401 with a descriptive message if a social account attempts password-based login.Middleware Reference
verificarToken
Applied to every protected route. It reads the Authorization header, verifies the JWT signature against JWT_SECRET, and loads the full user document from MongoDB into req.usuario.
| Status | Condition |
|---|---|
401 Token no proporcionado | Authorization header is missing or does not start with Bearer . |
401 Usuario no encontrado o inactivo | The id in the token payload does not match an active user in the database. |
401 Token inválido o expirado | JWT signature verification failed or the token has expired. |
soloAdmin
Placed after verificarToken on any route that requires admin privileges. Checks req.usuario.rol === 'admin':
soloAsociado
Placed after verificarToken on routes that only restaurant partners may access. Checks req.usuario.rol === 'asociado':
Protecting a Route
Middleware is composed in the route definition. The guards are always applied in the orderverificarToken → role guard (if needed):
Socket.io Authentication
Socket.io connections are authenticated in theio.use() middleware hook using the same JWT_SECRET. The client must pass the token in the auth object of the Socket.io handshake:
user:<userId>. The server uses this room to deliver targeted events (new messages, incoming calls, etc.) directly to that user regardless of which socket instance they are connected on.