Skip to content
This repository was archived by the owner on Aug 1, 2024. It is now read-only.

API.Routes.Login

Mestre-Tramador edited this page Oct 19, 2022 · 2 revisions

Login POST

/login

Try to authenticate a User on the system.

Headers

Name Value Description
Content-Type application/json The User credentials shall be passed as JSON.

Request Body

{
  "email": "user@exper.com",
  "password": "exper_password"
}
Field Type Required Description
email string true The email registered on the database.
password string true The password set.

Response

200

{
  "access_token": "eyJhbGciOiJIUzI1NiJ9.eyJwYXNzd29yZCI6ImV4cGVyX3Bhc3N3b3JkIiwiZW1haWwiOiJ1c2VyQGV4cGVyLmNvbSJ9.8FIAGHu2bfHb689bK7AXSgN_ow_T8A5h9XAjkCH8lQE",
  "token_type": "bearer",
  "user": {
    "id": 99,
    "name": "Matheus Mathias",
    "email": "matheus.math@exper.com",
    "creation": "2022-02-14 13:21:36"
  }
}

Returns the JWT to be used on further requests. It also give the User logged in.

202

{
  "message": "Already logged in"
}

If an attempt is made when a token is being used.

400

{
  "error": "There is no User with this credentials registered!"
}

This error occur when there is no User registered with the given email.

401

{
  "error": "Unauthorized"
}

This error occur when the given password is incorrect.

422

{
  "field": [
    "First problem with the field.",
    "Second problem..."
  ]
}

Each one of the Request Body fields can be a key, with an array of strings detailing the errors.

Clone this wiki locally