Creates an instance of AuthController
Service for user-related operations
Service for token blacklist management (required)
User login endpoint handler
Authenticates a user with email and password credentials, validates account status, generates JWT token pair, and updates last login timestamp. Implements security measures including input validation and comprehensive logging.
Express request object containing login credentials in body
Express response object for sending authentication response
Resolves when login process completes successfully
Token refresh endpoint handler
Validates and refreshes JWT tokens using a valid refresh token. Checks token blacklist, verifies user account status, and generates a new token pair. Implements security measures to prevent token reuse and unauthorized access.
Express request object containing refresh token in body
Express response object for sending new tokens
Resolves when token refresh completes successfully
User logout endpoint handler
Securely logs out a user by revoking their refresh token and adding it to the blacklist. Requires authentication via access token. Provides graceful handling when refresh token is not provided in the request body.
Express request object with authenticated user and optional refresh token in body
Express response object for sending logout confirmation
Resolves when logout process completes
User registration endpoint handler
Creates a new user account with email, password, and optional profile information. Validates input data, creates user with hashed password, assigns default role, and automatically logs in the user by generating JWT tokens.
Express request object containing registration data in body
Express response object for sending registration response
Resolves when registration and auto-login complete successfully
Get current authenticated user information endpoint handler
Retrieves comprehensive profile information for the currently authenticated user. Requires valid authentication via access token. Returns detailed user data including profile information, registration details, and account status.
Express request object with authenticated user information
Express response object for sending user profile data
Resolves when user information is successfully retrieved and sent
Authentication Controller Class
Handles all authentication-related HTTP endpoints for the WayrApp platform. This controller manages user registration, login, token refresh, logout, and profile retrieval. It integrates with UserService for user operations and TokenBlacklistService for security.
AuthController
Example