Enterprise User Authentication
POST/company/auth/login
Endpoint for authenticating administrative users of registered companies.
Performs the following operations:
- Validates email and password format
- Searches for the user in the database (both in company_user and trucker_user as a fallback)
- Verifies the password against the stored hash
- Checks the account status (active/blocked)
- Records the last IP and access date
- Generates a JWT token with user claims
- Logs the access in the history
- Verifies/creates a Stripe account if it does not exist
Detailed flow:
- Client sends email and password in JSON format
- Server validates required fields (400 if missing)
- Searches for the user by email (401 if not found)
- Verifies the password with bcrypt (401 if it does not match)
- Checks the account status (401 if inactive/blocked)
- Updates the last access data (IP, date)
- Generates a JWT token with user and company data
- Returns the token with expiration time
Security:
- Requires HTTPS
- Passwords are transmitted hashed
- Tokens have a configurable expiration
Example request:
\{
email: admin@company.com,
password: SecurePassword123!
\}
Example successful response:
\{
token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...,
expiresIn: 1712345678901
\}
Error codes:
- 400: Missing data or invalid format
- 401: Incorrect credentials, user does not exist, or inactive account
- 500: Internal server error
Request
Responses
- 200
- 400
- 401
Authentication successful
Invalid request
Unauthorized