v1

latestOpenAPI 3.0.3raw.githubusercontent.com2024-10-2916802.4 MB
🔐 Authentication

Login user

The API endpoint allows users to log into the application securely and also returns an access token.

When accessing this endpoint with valid login credentials, users will receive an access token in the response.

Additionally, the API endpoint securely sets the access token within the browser/client httpOnly cookies for future authentication and authorization purposes.

This functionality ensures a secure and efficient login process for users, providing them with an access token that can be used to authenticate subsequent API requests.

By securely storing the access token in browser cookies, the endpoint enables automatic inclusion of the access token in future API requests, eliminating the need for users to manually manage and provide the token with each request.

post/users/login

Request body

passwordstring
usernamestring

Example request

{
  "password": "test@123",
  "username": "doejohn"
}

Response

Login user

messagestring
statusCodenumber
successboolean

Example response

{
  "data": {
    "accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI2NDllNzk1MjY0ZTdkYmEyOWI3MjY5MzYiLCJlbWFpbCI6IndhamUuc2h1YmhhbTExMUBnbWFpbC5jb20iLCJ1c2VybmFtZSI6IndhamVzaHViaGFtIiwicm9sZSI6IkFETUlOIiwiaWF0IjoxNjg4MTA3NDY5LCJleHAiOjE2ODgxOTM4Njl9.40qfVrWi8x8fGBRB9JBVCVsdMYvlwzjIRpffz5z7DK4",
    "refreshToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI2NDllNzk1MjY0ZTdkYmEyOWI3MjY5MzYiLCJpYXQiOjE2ODgxMDc0NjksImV4cCI6MTY4ODk3MTQ2OX0.7or55Coj0K_UY4YpzYzkNR9hcOIhusxk9FRz7eMV8Ho",
    "user": {
      "_id": "649e795264e7dba29b726936",
      "avatar": {
        "_id": "649e795264e7dba29b726935",
        "url": "https://via.placeholder.com/200x200.png"
      },
      "createdAt": "2023-06-30T06:42:26.163Z",
      "email": "user.email@domain.com",
      "loginType": "EMAIL_PASSWORD",
      "role": "ADMIN",
      "updatedAt": "2023-06-30T06:44:29.831Z",
      "username": "doejohn"
    }
  },
  "message": "User logged in successfully",
  "statusCode": 200,
  "success": true
}