Skip to content

User methods

Fedor Kuznetsov edited this page Jun 27, 2023 · 6 revisions

POST auth/registration

Description:

This endpoint is used for user registration. The user needs to provide a unique username and a password for creating an account.

Request:

The request should be a JSON object containing the following fields:

  • username (string, required): The user's desired username.
  • password (string, required): The user's desired password.

Example:

{
  "username": "example_user",
  "password": "example_password"
}

Response:

If the registration is successful, the server will return a JSON object with the following fields:

  • token (string): A token that the user can use to authenticate and access protected resources.
  • message (string): A success message indicating that the registration was successful.
  • isSuccess (boolean): A boolean value indicating whether the registration was successful or not.

Example:

{
    "token" : "example_token",
    "message": "User registered successfully",
    "isSuccess": true
}

POST auth/login

Description:

This endpoint is used for user login. The user needs to provide their registered username and password to authenticate themselves and receive a token to access protected resources.

Request:

The request should be a JSON object containing the following fields:

  • username (string, required): The user's registered username.
  • password (string, required): The user's registered password.

Example:

{
  "username": "example_user",
  "password": "example_password"
}

Response:

If the login is successful, the server will return a JSON object with the following fields:

  • token (string): A token that the user can use to authenticate and access protected resources.
  • message (string): A message indicating that the login was successful.
  • isSuccess (boolean): A boolean value indicating whether the login was successful or not.

Example:

{
    "token": "example_token",
    "message": "Login successful",
    "isSuccess": true
}

POST auth/verify

Description:

This endpoint is used for verifying user tokens.

Request:

The request should be a JSON object containing the following fields:

  • token (string, required): The user's token to be verified.

Example:

{
  "token": "example_token"
}

Response:

If the verification is successful, the server will return a JSON object with the following fields:

token (null): A null value indicating that the token was successfully verified.

  • message (string): A success message indicating that the verification was successful.
  • isSuccess (boolean): A boolean value indicating whether the verification was successful or not.

Example:

{
    "token": null,
    "message": "Verification is successful",
    "isSuccess": true
}

Clone this wiki locally