Skip to main content

Login

Authenticate user and return access/refresh tokens via cookies and response body.

Request Body

email
string
required
User email address
password
string
required
User password (min 8 characters)

Response

message
string
Success message
data
object
expired
string
Token expiration timestamp
profile
object
id
string
User ID (UUID)
username
string
Username
email
string
Email address
role
string
User role: admin, manager, or cashier
avatar
string
Avatar URL
is_active
boolean
Account active status
created_at
string
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

message
string
Success message

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

message
string
Success message
data
object
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

old_password
string
required
Current password (8-32 characters)
new_password
string
required
New password (8-32 characters)

Response

message
string
Success message

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
file
required
Avatar image file (square image, minimum 300x300 pixels)

Response

message
string
Success message
data
object
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

message
string
Success message
data
object
expired
string
New token expiration timestamp
profile
object
User profile information

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
string
required
Username (3-32 characters)
email
string
required
Email address
password
string
required
Password (8-32 characters)
role
string
required
User role: admin, manager, or cashier

Response

message
string
Success message
data
object
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"
  }'

Build docs developers (and LLMs) love