Skip to content

Account endpoints

tkaixiang edited this page Aug 21, 2021 · 3 revisions

POST /v1/account/create

Creates a new account

Input

{
	"username": "NEW_USERNAME",
	"password": "NEW_PASSWORD",
	"email": "NEW EMAIL"
}

Output

{
	"success": true
}

Errors

Error Definition
username-taken The username submitted is already in use
email-taken The email submitted is already in use
email-formatting The email submitted was malformed

POST /v1/account/delete

Deletes multiple accounts (or own account)
Authenticated // Permissions: 2 for deleting other accounts

Input

Admin Input:

{
	"users": ["username1 to delete", "user2"...]
}

If deleting own account:

{
	"password": "user_password"
}

Output

{
	"success": true
}

Remarks

  • If users is empty, the own user will be deleted
  • users can only be defined by a user with permissions level 2
  • If users is defined, the own user's account cannot be deleted as a precaution
  • This endpoint is very slow

Errors

Error Definition
permissions The logged-in user does not have sufficient permissions to delete another user
not_found None of the users supplied exist
wrong_password The password the user entered to delete their own account was incorrect

POST /v1/account/taken/username

Checks if a username has been taken

Input

{
	"username": "USERNAME_TO_CHECK"
}

Output

{
	"success": true,
	"taken": "bool"
}

Remarks

  • Do not ping this endpoint on every keystroke (check after user stops typing for a certain delay)

Errors

No special errors

POST /v1/account/taken/email

Checks if an email address has been taken

Input

{
	"email": "EMAIL_ADDRESS_TO_CHECK"
}

Output

{
	"success": true,
	"taken": "bool"
}

Remarks

  • Do not ping this endpoint on every keystroke (check after user stops typing for a certain delay)

Errors

No special errors

POST /v1/account/login

Login endpoint

Input

{
	"username": "USERNAME",
	"password": "PASSWORD"
}

Output

{
	"success": true,
	"permissions": 0-2 (int from 0-2),
	"token": "TOKEN_STRING"
}

Remarks

  • Do not process the token. Store it directly as its format may change without notice.

Errors

Error Definition
wrong-details The wrong username/password was entered

POST /v1/account/type

Returns the updated permissions level of the logged-in user
Authenticated

Input

No input required

Output

{
	"success": true,
	"type": 0-2(int from 0-2)
}

Errors

No special errors

POST /v1/account/password

Change the password of the user
Authenticated

Input

{
	"password": "OLD_PASSWORD",
	"new_password": "NEW_PASSWORD"
}

Output

{
	"success": true
}

Errors

Error Definition
not-found The username specified was not found
empty-password The new_password field is empty
wrong-password The password field does not match the old password

GET /v1/account/list

List all accounts
Authenticated // Permissions: 2

Input

None

Output

{
	"success": true,
	"list": [
		{
			"username": "USERNAME_OF_USER",
			"email": "USER_EMAIL_ADDRESS",
			"type": "int from 0-2 (permissions level)",
			"score": "int"
		},
		{
			"username": "USERNAME_OF_USER",
			"email": "USER_EMAIL_ADDRESS",
			"type": "int from 0-2 (permissions level)",
			"score": "int"
		}
	]
}

Errors

Error Definition
permissions The logged-in user does not have sufficient permissions to list all users

POST /v1/account/adminChangePassword

Changes the password of an account Authenticated // Permissions: 2

Input

{
	"username": "USERNAME_OF_ACCOUNT_TO_CHANGE",
	"password": "new_password"
}

Output

{
	"success": true
}

Errors

Error Definition
permissions The logged-in user does not have sufficient permissions to change another user's permission
empty-password The password field is empty

POST /v1/account/permissions

Changes the permissions of an account
Authenticated // Permissions: 2

Input

{
	"username": "USERNAME_OF_ACCOUNT_TO_CHANGE",
	"type": "int from 0-2 (new permissions level)"
}

Output

{
	"success": true
}

Errors

Error Definition
permissions The logged-in user does not have sufficient permissions to change another user's permission
out-of-range type is not between 0 to 2

GET /v1/account/disableStates

Retrieves the states of the users settings in the admin panel Authenticated // Permissions: 2

Input

None

Output

{
	"success": true,
    "states": []
}

Errors

Error Definition
permissions The logged-in user does not have sufficient permissions to change another user's permission
out-of-range type is not between 0 to 2