🔐 Authentication Service

API Endpoints Documentation

📋 Service Information

Service Name: Authentication Service

Port: 8050

Base URL: http://localhost:8050

Description: Handles user authentication, registration, password management, and email notifications

Features: JWT tokens, email integration (Mailtrap), user types (SIMPLE_USER, VIP_USER), advanced search

📧 Email Integration

Professional HTML email templates with Mailtrap integration for forgot/reset password functionality

🔑 JWT Authentication

Secure token-based authentication with user claims and role-based access

👥 User Types

Support for SIMPLE_USER and VIP_USER types with different privileges

🔍 Advanced Search

JSON-based search with pagination, filtering, and sorting capabilities

👨‍💼 Employee/Registration Endpoints
POST /auth/login

Employee Login

Authenticate employee/registration users and receive JWT token

📝 Request Example:

curl -X POST http://localhost:8050/auth/login \ -H "Content-Type: application/json" \ -d '{ ... }'

📄 Request Body:

{ "email": "employee@example.com", "password": "password123" }

📤 Response:

{ "data": { "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...", "UserType": "EMPLOYEE" }, "message": "Login successful", "status": "success", "statusCode": 200 }
200 - Success 401 - Invalid Credentials 500 - Server Error
POST /auth/forgot-password

Forgot Password

Send password reset email to employee/registration users

📝 Request Example:

curl -X POST http://localhost:8050/auth/forgot-password \ -H "Content-Type: application/json" \ -d '"employee@example.com"'
200 - Email Sent 404 - Email Not Found 500 - Server Error
POST /auth/reset-password

Reset Password

Reset password using token from email

📝 Request Example:

curl -X POST "http://localhost:8050/auth/reset-password?token=abc123&newPassword=newpass123"
📌 Query Parameters:

token - Reset token from email

newPassword - New password

200 - Password Reset 400 - Invalid/Expired Token 404 - User Not Found
🌐 Web User Endpoints
POST /web-user/register

Web User Registration

Register new web users with user type support

📝 Request Example:

curl -X POST http://localhost:8050/web-user/register \ -H "Content-Type: application/json" \ -d '{ ... }'

📄 Request Body:

{ "firstName": "John", "lastName": "Doe", "email": "john@example.com", "password": "password123", "phone": "+1234567890", "gender": "MALE", "userType": "VIP_USER" }
📌 User Types:

SIMPLE_USER - Basic user privileges

VIP_USER - Enhanced user privileges

201 - User Created 409 - Email Already Exists 500 - Server Error
POST /web-user/login

Web User Login

Authenticate web users and receive JWT token with user details

📝 Request Example:

curl -X POST http://localhost:8050/web-user/login \ -H "Content-Type: application/json" \ -d '{ ... }'

📄 Request Body:

{ "email": "john@example.com", "password": "password123" }
200 - Success 401 - Invalid Credentials 403 - Account Deactivated
GET /web-user/list

List Web Users

Get list of all web users with basic information

📝 Request Example:

curl -X GET http://localhost:8050/web-user/list
200 - Success 500 - Server Error
POST /web-user/search

Advanced Search

Search web users with JSON-based criteria and pagination

📝 Request Example:

curl -X POST http://localhost:8050/web-user/search \ -H "Content-Type: application/json" \ -d '{ ... }'

📄 Request Body:

{ "searchTerm": "john", "gender": "MALE", "userType": "VIP_USER", "isActive": true, "page": 0, "size": 10, "sortBy": "createdAt", "sortDirection": "desc" }
200 - Success 400 - Invalid Search Criteria 500 - Server Error
GET /web-user/list-paginated

Paginated List

Get paginated list of web users with query parameters

📝 Request Example:

curl -X GET "http://localhost:8050/web-user/list-paginated?page=0&size=10&userType=VIP_USER"
📌 Query Parameters:

page - Page number (default: 0)

size - Page size (default: 10)

searchTerm - Search in name, email, phone

gender - Filter by gender (MALE, FEMALE)

userType - Filter by user type (SIMPLE_USER, VIP_USER)

isActive - Filter by active status (true, false)

200 - Success 500 - Server Error
POST /web-user/forgot-password

Web User Forgot Password

Send password reset email to web users

📝 Request Example:

curl -X POST http://localhost:8050/web-user/forgot-password \ -H "Content-Type: application/json" \ -d '"john@example.com"'
200 - Email Sent 404 - Email Not Found 500 - Server Error
POST /web-user/reset-password

Web User Reset Password

Reset password using token from email

📝 Request Example:

curl -X POST "http://localhost:8050/web-user/reset-password?token=abc123&newPassword=newpass123"
📌 Query Parameters:

token - Reset token from email

newPassword - New password

200 - Password Reset 400 - Invalid/Expired Token 404 - User Not Found

📧 Email Features

Mailtrap Integration: Professional HTML email templates with responsive design

Templates: Forgot password and password reset confirmation emails

Security: 30-minute token expiry, one-time use tokens, encrypted passwords

Personalization: User name personalization and security tips