Login
Authenticate user and return access/refresh tokens via cookies and response body.
Request Body
User password (min 8 characters)
Response
Token expiration timestamp
User role: admin, manager, or cashier
Account creation timestamp
Example
curl -X POST https://localhost:8080/api/v1/auth/login \
-H "Content-Type: application/json" \
-d '{
"email": "[email protected]",
"password": "password123"
}'
{
"message": "Success",
"data": {
"expired": "2024-03-04T10:00:00Z",
"profile": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"username": "admin",
"email": "[email protected]",
"role": "admin",
"avatar": "https://storage.example.com/avatars/admin.jpg",
"is_active": true,
"created_at": "2024-01-01T00:00:00Z"
}
}
}
Logout
Clear access and refresh token cookies to log out the current user.Authentication Required: YesRoles: admin, manager, cashier
Response
Example
curl -X POST https://localhost:8080/api/v1/auth/logout \
-H "Cookie: access_token=YOUR_TOKEN"
{
"message": "Successfully logged out"
}
Get Current Profile
Get detailed profile information for the authenticated user session.Authentication Required: YesRoles: admin, manager, cashier
Response
Profile information (see Login response for schema)
Example
curl -X GET https://localhost:8080/api/v1/auth/me \
-H "Cookie: access_token=YOUR_TOKEN"
Update Password
Update the password for the current user session.Authentication Required: YesRoles: admin, manager, cashier
Request Body
Current password (8-32 characters)
New password (8-32 characters)
Response
Example
curl -X PUT https://localhost:8080/api/v1/auth/me/password \
-H "Content-Type: application/json" \
-H "Cookie: access_token=YOUR_TOKEN" \
-d '{
"old_password": "oldpass123",
"new_password": "newpass456"
}'
Update Avatar
Upload and update the profile picture for the current user.Authentication Required: YesRoles: admin, manager, cashier
Request Body (multipart/form-data)
Avatar image file (square image, minimum 300x300 pixels)
Response
Updated profile information
Example
curl -X PUT https://localhost:8080/api/v1/auth/me/avatar \
-H "Cookie: access_token=YOUR_TOKEN" \
-F "avatar=@/path/to/avatar.jpg"
Refresh Token
Issue a new access token using a valid refresh token cookie.
Response
New token expiration timestamp
Example
curl -X POST https://localhost:8080/api/v1/auth/refresh \
-H "Cookie: refresh_token=YOUR_REFRESH_TOKEN"
Add New User
Register a new user with a specific role.Authentication Required: YesRoles: admin
Request Body
Username (3-32 characters)
Password (8-32 characters)
User role: admin, manager, or cashier
Response
Created user profile information
Example
curl -X POST https://localhost:8080/api/v1/auth/add \
-H "Content-Type: application/json" \
-H "Cookie: access_token=YOUR_TOKEN" \
-d '{
"username": "newuser",
"email": "[email protected]",
"password": "password123",
"role": "cashier"
}'