Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/JaiderT/CoffeePrice/llms.txt

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

CoffePrice’s authentication layer supports two sign-in strategies: email/password with email verification and Google OAuth 2.0. All authenticated sessions are tracked via a signed JWT stored in a secure, HttpOnly cookie. Every auth endpoint is rate-limited at the middleware level to protect against brute-force and enumeration attacks.

Authentication Mechanism

After a successful login or registration flow, the server issues a JWT and stores it in an HttpOnly cookie named auth_token. Subsequent requests to protected routes are automatically authenticated via that cookie. If you need to authenticate without cookie support (e.g., from a native mobile client or server-to-server context), you can pass the token in the Authorization header instead:
Authorization: Bearer <token>
The middleware checks req.cookies.auth_token first, then falls back to the Authorization header.

Token Expiry

Token lifetime is controlled by the JWT_EXPIRES_IN environment variable. If not set, the default is 7d (seven days).
JWT_EXPIRES_IN=1d   # example: set token to expire after 1 day

Rate Limits

All auth endpoints are guarded by express-rate-limit. Limits apply per IP address over a 15-minute rolling window.
LimiterEndpointMax requests / 15 min
loginLimiterPOST /api/auth/login10
registerLimiterPOST /api/auth/register100
verifyLimiterPOST /api/auth/verify-email6
resendVerificationLimiterPOST /api/auth/resend-verification4
When a limit is exceeded the server responds with HTTP 429 and a JSON body describing the error. Rate-limit metadata is returned via standard RateLimit-* response headers (standardHeaders: true).

Account States and API Access

Every user record carries an estado field that gates access to protected routes. The middleware evaluates this field on every authenticated request.
EstadoAccess level
activoFull access to all protected routes.
pendiente (non-comprador)Restricted to GET /api/auth/me and POST /api/auth/logout only.
pendiente (comprador rol)Can access all /api/comprador routes plus GET /api/auth/me and POST /api/auth/logout.
suspendidoLimited to POST /api/usuario/reactivar, GET /api/auth/me, and POST /api/auth/logout.
rechazadoBlocked from all protected routes. Returns 403 Cuenta rechazada.
eliminadoBlocked from all protected routes. Returns 403 Esta cuenta ha sido eliminada.

Endpoints Summary

MethodPathAuth RequiredDescription
POST/api/auth/registerNoCreate a new account (productor or comprador).
POST/api/auth/loginNoAuthenticate with email and password; sets auth cookie.
POST/api/auth/verify-emailNoSubmit the 6-digit verification code sent by email.
POST/api/auth/resend-verificationNoRe-send the 6-digit verification code to the user.
GET/api/auth/meYesReturn the currently authenticated user’s profile.
POST/api/auth/logoutNoClear the auth cookie and destroy the session.
GET/api/auth/googleNoInitiate Google OAuth 2.0 flow (pass ?rol= param).
GET/api/auth/google/callbackNoOAuth callback; sets auth cookie and redirects frontend.

Explore the Auth Endpoints

Register

Create a new account with email and password.

Login

Authenticate and manage your session.

Google OAuth

Sign in with a Google account via OAuth 2.0.

Build docs developers (and LLMs) love