User Management API Documentation

Base Path

/user

Endpoints

User Login

POST /login

Request Body

{
  username: string,  // Username
  password: string   // Password
}

Note

  • Rate limit: 100 requests per 15 minutes

User Logout

POST /logout

Update User Information

PUT /

Request Body

{
  username: string,  // Username
  password: string   // Password
}

Get User Information

GET /

Two-Factor Authentication

Initialize Two-Factor

GET /two-factor/init

Activate Two-Factor

PUT /two-factor/active

Request Body

{
  code: string  // Verification code
}

Deactivate Two-Factor

PUT /two-factor/deactivate

Two-Factor Login

PUT /two-factor/login

Request Body

{
  code: string,     // Verification code
  username: string, // Username
  password: string  // Password
}

Two-factor login is limited to 20 requests per 15 minutes.

Login Log

GET /login-log

IP Blacklist

Use GET /ip-blacklist to list blocked addresses, PUT /ip-blacklist to block an address, and DELETE /ip-blacklist to unblock it. PUT and DELETE take a JSON body:

{"ip":"192.0.2.1"}

ip is required and accepts a single IPv4 or IPv6 address. CIDR ranges are not accepted.

Notification Settings

Get Notification Settings

GET /notification

Update Notification Settings

PUT /notification

Initialization

Initialize User Information

PUT /init

Request Body

{
  username: string,  // Username
  password: string   // Password
}

Initialize Notification Settings

PUT /notification/init

Update Avatar

PUT /avatar

Request Body

  • Content-Type: multipart/form-data
  • Field: avatar (file)
  • One file, at most 5 MiB. Supports PNG, JPEG, GIF, WebP and AVIF; the extension must match the MIME type.

Error Handling

  • All endpoints follow unified error handling mechanism
  • Successful responses return { code: 200, data: ... }
  • Error logging is handled by Winston logger

Notes

  • Parameter validation using celebrate/Joi
  • File uploads handled by multer
  • Avatar filenames generated using UUID
  • Some features are restricted in demo environment