Skip to content

Commit

Permalink
Documentation page for finishing password recovery
Browse files Browse the repository at this point in the history
  • Loading branch information
BrunoRosendo committed Sep 12, 2022
1 parent c333430 commit 4779cba
Show file tree
Hide file tree
Showing 4 changed files with 151 additions and 4 deletions.
3 changes: 2 additions & 1 deletion documentation/docs-index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ module.exports = {
"auth/logout",
"auth/register",
"auth/recover",
"auth/token"
"auth/confirm",
"auth/finish-recovery"
]
},
};
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
id: token
id: confirm
title: Confirm Recovery Token
sidebar_label: Confirm Recovery Token
slug: /auth/token
slug: /auth/confirm
---

import Tabs from '@theme/Tabs';
Expand All @@ -13,7 +13,7 @@ import Highlight from "../../src/highlight.js"
## Details

This endpoint is used to check if the given token is valid to recover an account.
The token can be generated by using the [recover](./recover.md) endpoint and is sent to the user by email.
The token can be generated by using the [recover](./recover) endpoint and is sent to the user by email.

**URL** : `/auth/recover/:token/confirm`

Expand Down
142 changes: 142 additions & 0 deletions documentation/docs/auth/finish-recovery.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
---
id: finish-recovery
title: Finish Password Recovery
sidebar_label: Finish Password Recovery
slug: /auth/finish-recovery
---

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

import Highlight from "../../src/highlight.js"

## Details

This endpoint is used to change the password of an account, given a previously generated token.
The token can be generated by using the [recover](./recover) endpoint and is sent to the user by email.

**URL** : `/auth/recover/:token/confirm`

**Method** : <Highlight level="info" inline>POST</Highlight>

## Parameters

### password

<Highlight level="info" inline>Body Parameter</Highlight>
<Highlight level="danger" inline>Required</Highlight>
<br/>
<Highlight level="secondary" inline>String</Highlight>
<Highlight level="warning" inline>Min Length: 8</Highlight>

New password for the account. Must contain at least one number.

## Request examples

### Example 1 - Valid Token

**Code** : <Highlight level="success" inline>200 OK</Highlight>

<Tabs
defaultValue="request"
values={[
{label: 'Request', value: 'request'},
{label: 'Response', value: 'response'},
]}
>
<TabItem value="request">

```json
{
"password": "newpassword123"
}
```

</TabItem>

<TabItem value="response">

```json
{}
```

</TabItem>
</Tabs>

### Example 2 - Invalid Token

**Code** : <Highlight level="danger" inline>403 FORBIDDEN</Highlight>

<Tabs
defaultValue="request"
values={[
{label: 'Request', value: 'request'},
{label: 'Response', value: 'response'},
]}
>
<TabItem value="request">

```bash
/auth/recover/invalid/confirm
```

</TabItem>

<TabItem value="response">

```json
{
"error_code": 3,
"errors": [
{
"msg": "invalid-token"
}
]
}
```

</TabItem>
</Tabs>

### Example 3 - Password Without Numbers

**Code** : <Highlight level="danger" inline>422 UNPROCESSABLE ENTITY</Highlight>

<Tabs
defaultValue="request"
values={[
{label: 'Request', value: 'request'},
{label: 'Response', value: 'response'},
]}
>
<TabItem value="request">

```json
{
"password": "newpassword"
}
```

</TabItem>

<TabItem value="response">

```json
{
"error_code": 1,
"errors": [
{
"value": "newpassword",
"msg": "must-contain-number",
"param": "password",
"location": "body"
}
]
}
```

</TabItem>
</Tabs>
4 changes: 4 additions & 0 deletions documentation/docs/auth/recover.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ Returns 200 status even if the account doesn't exist (for safety purposes).

**Method** : <Highlight level="info" inline>POST</Highlight>

:::info Following steps
To continue the flow of recovering an account, see [confirm token](./confirm) and [finish recovery](./finish-recovery).
:::

## Parameters

### email
Expand Down

0 comments on commit 4779cba

Please sign in to comment.