Account
This page contains the documentation for the account endpoints.
The account endpoints allow you to register an account, get an API key, validate your key, get users' details, and edit a user's details.
This endpoint allows you to register a user. Once registered, it will return an API key.
The name of the user.
The email address of the user.
The password for the account.
Specifies whether the user has administrative privileges.
false
POST /auth/register HTTP/1.1
Host: thefurniturebros.com
Content-Type: application/json
Accept: */*
Content-Length: 70
{
"name": "john doe",
"email": "john_doe12@gmail.com",
"password": "123456"
}
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cBGlR1fkzXQKgxLshzVL2lcajQNXEUTH09N-csr98"
}
This endpoint allows you to login to an account and retrieve an API key.
The email address of the user.
The password of the account.
POST /auth/login HTTP/1.1
Host: thefurniturebros.com
Content-Type: application/json
Accept: */*
Content-Length: 52
{
"email": "john_doe12@gmail.com",
"password": "123456"
}
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjp7ImlkIjoiNjc0ODhjYWE4ZGQxZmYzZDNlYjk0NTQxIiwiYWRtaW4iOnRydWV9LCJpYXQiOjE3MzI4MDc4ODEsImV4cCI6MTczMjg0Mzg4MX0.aFBDj34nuuNkt95G71QbL7KJTotLyNE0Lu9BKe4Zv0s",
"user": {
"_id": "67488caa8dd1ff3d3eb94541",
"name": "test name",
"email": "name_test_admin@gmail.com",
"password": "$2a$10$767ZSzTiC0Jm.8p/Jmyx1eqnciqWn7GCUDA/I7AbiTgmqHfJc/mfC",
"admin": true,
"__v": 0
}
}
This endpoint allows you to validate your API key.
GET /auth/validate HTTP/1.1
Host: thefurniturebros.com
Authorization: YOUR_API_KEY
Accept: */*
{
"authenticate": true,
"admin": false
}
This endpoint allows you to get the info about the users in the application.
The page number to retrieve (1-based index). Each page returns 20 users.
GET /users/get_all/{page} HTTP/1.1
Host: thefurniturebros.com
Authorization: YOUR_API_KEY
Accept: */*
{
"totalUsers": 51,
"adminUsers": 11,
"regularUsers": 40,
"users": [
{
"_id": "6555a0f89feeac7dccd9b1dd",
"name": "first account",
"email": "first_account@gmail.com",
"password": "$2a$10$jK1bvjH7D/pdjI6mVb9uSuXMeWwcFwhlBYIh7Wqf0CLsey9I3Epx2",
"admin": false,
"__v": 0
}
]
}
This endpoint allows you to edit a user's details. This requires admin privileges.
The user ID of the account to modify.
You can get the list of user ID by using the POST /users/get_all/{page}
endpoint.
The new name for the user.
The new email for the user.
The new admin status for the user.
true
: The user has admin privileges.false
: The user does not have admin previleges.
POST /users/edit HTTP/1.1
Host: thefurniturebros.com
Authorization: YOUR_API_KEY
Content-Type: application/json
Accept: */*
Content-Length: 116
{
"userId": "674605a2a18c2f38f2148601",
"newName": "Jane Doe",
"newEmail": "jane_example@gmail.com",
"newAdminStatus": true
}
{
"user": {
"_id": "674605a2a18c2f38f2148601",
"name": "Jane Doe",
"email": "jane_example@gmail.com",
"password": "$2a$10$eaixU5.H3PFYW.9V6NM8A.A.CPnFHtbcWPWsp/I1NWsfxqIG6s87K",
"admin": false,
"__v": 0
}
}
Last updated