# Login

## Realizar Login

<mark style="color:green;">`POST`</mark> `https://sol.interfoneip.com/auth/app`

Necessário para receber o token

#### Request Body

| Name  | Type   | Description        |
| ----- | ------ | ------------------ |
| login | string | Telefone ou E-Mail |

{% tabs %}
{% tab title="200 O retorno "type" depende do que foi enviado pelo  login, se foi um e-mail ou um telefone (Para saber onde vai receber o código)" %}

```javascript
{
    "message": "Success",
    "type": "M"
}
```

{% endtab %}

{% tab title="404 " %}

```javascript
{
    "error": "User not found!"
}
```

{% endtab %}
{% endtabs %}

## Confirmar Token

<mark style="color:green;">`POST`</mark> `https://sol.interfoneip.com/auth/app/token`

Validar o token recebido pelo endpoint anterior

#### Request Body

| Name         | Type   | Description                                          |
| ------------ | ------ | ---------------------------------------------------- |
| token        | string | Código de 4 dígitos recebido pelo telefone ou e-mail |
| login        | string | Telefone ou E-mail fornecido no endpoint anterior    |
| mac\_address | string | Mac Adress do dispositivo a conectar                 |

{% tabs %}
{% tab title="200 " %}

```javascript
{
    "token": "XXXXXXXX.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.XXXXXX"
}
```

{% endtab %}

{% tab title="401 " %}

```javascript
{
    "error": "Access Denied!"
}
```

{% endtab %}
{% endtabs %}

## Validar Token

<mark style="color:green;">`POST`</mark> `https://sol.interfoneip.com`

#### Headers

| Name           | Type   | Description      |
| -------------- | ------ | ---------------- |
| Authentication | string | Bearer JWT Token |

#### Request Body

| Name         | Type   | Description                                |
| ------------ | ------ | ------------------------------------------ |
| token        | string | Token JWT Fornecido pelo endpoint anterior |
| mac\_address | string | Mac Address do dispositivo conectado       |

{% tabs %}
{% tab title="200 " %}

```
```

{% endtab %}
{% endtabs %}

## Realizar login (Site)

<mark style="color:green;">`POST`</mark> `https://sol.interfoneip.com/auth`

O token adquirido precisa ser fornecido via Authorization para todas as solicitações seguintes

#### Request Body

| Name            | Type    | Description                      |
| --------------- | ------- | -------------------------------- |
| manterConectado | boolean | Manter conectado por mais tempo  |
| login           | string  | Usuário (login, telefone, email) |
| senha           | string  | Senha                            |

{% tabs %}
{% tab title="200 " %}

```javascript
{
    "token": "eyJ0eXAiOiJKsadLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJsdW1lbi1qd3QiLCJzdWIiOjksrhdhgdCI6MTU3MTAwMjE2MCwiZXhwIjoxNTcxMDMwOTYwfQ.zi-eCTkunyJYkPu023fqkkkBBeKNDVHBEeesjPkuQFA"
}
```

{% endtab %}

{% tab title="403 " %}

```
{
    "error": "Login or password is wrong."
}
```

{% endtab %}
{% endtabs %}
