POST /api/auth/login
Authenticates a user with email and password credentials. On successful login, sets access and refresh tokens as HTTP-only cookies and updates the user’s last login timestamp.Authentication
No authentication required.Request Body
User’s email address.
User’s password.
Response
Success message confirming login.
Cookies Set
accessToken- JWT access token (HTTP-only, secure in production, 7 days expiry)refreshToken- JWT refresh token (HTTP-only, secure in production, 7 days expiry)
Example Request
Example Response
Error Responses
Error message describing what went wrong.
400 Bad Request
- Email and password are required - One or both credentials are missing
401 Unauthorized
- Invalid email or password - Credentials don’t match any user account
- User account is inactive - The user account has been deactivated
500 Internal Server Error
- Server error with error message details
Notes
- Password is verified using bcrypt comparison (see
~/workspace/source/src/models/User.js:80) - The
lastLoginfield is updated with the current timestamp on successful login (see~/workspace/source/src/api/auth/login.js:29) - Cookies use
sameSite: 'strict'for CSRF protection - In production, cookies are set with the
secureflag (HTTPS only) - Both access and refresh tokens have a 7-day expiry
- Users must have
isActive: trueto login successfully