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
Successful response. Returns an object containing the API key.
See message description.
see message description.
POST /auth/register HTTP/1.1
Host: thefurniturebros.com
Content-Type: application/json
Accept: */*
Content-Length: 70
{
"name": "john doe",
"email": "[email protected]",
"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.
Successful response. Returns an object containing the API key and the information about the user.
See message description.
see message description.
POST /auth/login HTTP/1.1
Host: thefurniturebros.com
Content-Type: application/json
Accept: */*
Content-Length: 52
{
"email": "[email protected]",
"password": "123456"
}
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjp7ImlkIjoiNjc0ODhjYWE4ZGQxZmYzZDNlYjk0NTQxIiwiYWRtaW4iOnRydWV9LCJpYXQiOjE3MzI4MDc4ODEsImV4cCI6MTczMjg0Mzg4MX0.aFBDj34nuuNkt95G71QbL7KJTotLyNE0Lu9BKe4Zv0s",
"user": {
"_id": "67488caa8dd1ff3d3eb94541",
"name": "test name",
"email": "[email protected]",
"password": "$2a$10$767ZSzTiC0Jm.8p/Jmyx1eqnciqWn7GCUDA/I7AbiTgmqHfJc/mfC",
"admin": true,
"__v": 0
}
}
This endpoint allows you to validate your API key.
Successful response. Returns an object containing information related to the user's access privilege.
See message description.
see message description.
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.
Successful response. Returns an object with users statistics in the application.
See message description.
see message description.
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": "[email protected]",
"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.
Successful response. Returns an object containing user information.
See message description.
see message description.
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": "[email protected]",
"newAdminStatus": true
}
{
"user": {
"_id": "674605a2a18c2f38f2148601",
"name": "Jane Doe",
"email": "[email protected]",
"password": "$2a$10$eaixU5.H3PFYW.9V6NM8A.A.CPnFHtbcWPWsp/I1NWsfxqIG6s87K",
"admin": false,
"__v": 0
}
}
Last updated