Authentication

Register a new user

post

Create a new user account

Body
usernamestring · min: 1Required
passwordstring · min: 8Required
Responses
200
User registered successfully
application/json
post
POST /api/auth/register HTTP/1.1
Host: localhost:3000
Content-Type: application/json
Accept: */*
Content-Length: 37

{
  "username": "text",
  "password": "text"
}
{
  "token": "text",
  "permissions": [
    "text"
  ]
}

User login

post

Login with username and password

Body
usernamestringRequired
passwordstringRequired
Responses
200
Login successful
application/json
post
POST /api/auth/login HTTP/1.1
Host: localhost:3000
Content-Type: application/json
Accept: */*
Content-Length: 37

{
  "username": "text",
  "password": "text"
}
{
  "token": "text",
  "permissions": [
    "text"
  ]
}

Get current authentication state

get

Returns the current user's authentication status and permissions

Authorizations
Responses
200
Authentication state
application/json
get
GET /api/auth/state HTTP/1.1
Host: localhost:3000
Authorization: Bearer JWT
Accept: */*
{
  "authenticated": true,
  "username": "text",
  "permissions": [
    "text"
  ]
}

Update user profile

put

Update current user's username and/or password

Authorizations
Body
newUsernamestring · min: 1Optional
currentPasswordstringOptional
newPasswordstring · min: 8Optional
Responses
200
Profile updated successfully
application/json
put
PUT /api/auth/profile HTTP/1.1
Host: localhost:3000
Authorization: Bearer JWT
Content-Type: application/json
Accept: */*
Content-Length: 68

{
  "newUsername": "text",
  "currentPassword": "text",
  "newPassword": "text"
}
{
  "message": "text",
  "token": "text",
  "permissions": [
    "text"
  ]
}

Was this helpful?