Authentication
Login
Authenticate user and create session
POST
Login
Endpoint
Overview
Authenticates a user with email and password. If 2FA is enabled, returns a pending token that requires verification code. Otherwise, returns a full JWT token and user’s service access information.Request
User email address
User password
Required if 2FA is enabled. TOTP code from authenticator app.
Response (Without 2FA or Valid Code)
Authenticated user object
JWT token for authentication
Array of user’s service entitlements
Whether the user account is banned
Whether the user account is disabled
Response (2FA Required)
Partial user object (without sensitive data)
Always
true when 2FA is requiredTemporary token for 2FA verification. Not a full JWT token.
“2FA verification required”
Implementation Details
Process Flow
- CORS & Arcjet: Validates CORS and applies rate limiting
- User Lookup: Finds user with service access included
- Password Verification: Compares password with bcrypt hash
- 2FA Check: If enabled, validates verification code or returns pending token
- Session Management:
- Reuses existing session if valid and from same IP
- Creates new session if none exists
- Updates expiration on existing sessions
- Audit Logging: Logs
USER_LOGINandSESSION_CREATE(if new session)
Code Reference
Status Codes
Login successful (with or without 2FA)
Validation error
Invalid credentials or invalid 2FA code
Blocked by Arcjet
Server error or 2FA configuration error
Example Requests
Without 2FA
With 2FA
Session Reuse Logic
The endpoint implements smart session reuse:- If a valid session exists for the user from the same IP, it reuses the token
- Session expiration is updated on reuse
- New sessions are only created when none exist or existing session is invalid
Audit Events
- USER_LOGIN: Successful login (includes
twoFactorUsedflag) - SESSION_CREATE: New session created (only if new session was created)
Login