Skip to content

0.1 | User and Authentication API

Liu Yuxuan edited this page Dec 11, 2021 · 1 revision

Authentication

To perform any login services, a JWT token must be in the header of the request.

POST /auth/login

Log in to a user account.

body: { username: String, password: String }

return: A JWT token if success. entity: { accessToken, user: { _id, username, name } }.

User Manipulations

If the header of the request does not contain a valid token, or the token has expired, the operation will not be performed.

POST /user

Create a new user.

body: { username: String, password: String, name: String }

header: Authorization: "Bearer TOKEN"

return: The created user.

DELETE /user

Delete a user.

body: { username: String }

header: Authorization: "Bearer TOKEN"

return: The deleted user.

GET /user

Get users based on the given key-value pair. The key should be either username or name. The value should be part of the content for the given key but not case-sensitive. If the value is an empty string, all users will be returned

body: { key: String, value: String }

header: Authorization: "Bearer TOKEN"

return: Array of users. Password attribute will not be return