Skip to content

Commit

Permalink
Merge pull request #209 from spree/document-account-endpoints
Browse files Browse the repository at this point in the history
Add password reset descriptions to README
  • Loading branch information
tniezg authored Jun 7, 2021
2 parents 9177d04 + 5dbb0f5 commit ac0fc88
Showing 1 changed file with 63 additions and 1 deletion.
64 changes: 63 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ Developed and maintained by:
- [refreshToken](#refreshToken)
- [Account](#account)
- [create](#create)
- [forgotPassword](#forgotPassword)
- [resetPassword](#resetPassword)
- [update](#update)
- [accountInfo](#accountInfo)
- [creditCardsList](#creditCardsList)
Expand Down Expand Up @@ -130,7 +132,7 @@ The specific type of error returned by `fail()` can be determined using [`instan

## Tokens

Most endpoints require a token for authentication. It can be either an Order Token or Bearer Token.
Most endpoints require a token for authentication. It can be an Order Token, Bearer Token or a Confirmation Token.

### Order token

Expand All @@ -155,6 +157,10 @@ const response = await client.authentication.getToken({
const bearerToken: string = response.success().access_token
```

### Confirmation token

Identifies a user for a single operation. For example, to reset their account's password. Confirmation Tokens are single-use and may have an expiration date.

## Endpoints

Spree Storefront API SDK contains each endpoint according to [Spree Guides](https://guides.spreecommerce.org/api/v2/storefront)
Expand Down Expand Up @@ -281,6 +287,62 @@ data: {
const response = await client.account.confirm('2xssfC9Hzf8DJXyRZGmB')
```

### `forgotPassword`

Sends an account recovery link to the provided email address. The link allows resetting the password for the account.

**Parameters schema:**

```ts
user: {
email: string
}
```

**Success response schema:** [Success schema](#success-schema)

**Failure response schema:** [Error schema](#error-schema)

**Example:**

```ts
const response = await client.account.forgotPassword({
user: {
email: '[email protected]'
}
})
```

### `resetPassword`

Changes the password associated with the account using an account recovery token.

**Parameters schema:**

```ts
user: {
password: string
password_confirmation: string
}
```

**Required token:** [Confirmation token](#confirmation-token)

**Success response schema:** [Success schema](#success-schema)

**Failure response schema:** [Error schema](#error-schema)

**Example:**

```ts
const response = await client.account.resetPassword('7381273269536713689562374856', {
user: {
password: '123!@#asdASD',
password_confirmation: '123!@#asdASD'
}
})
```

### `update`

Updates account and returns its attributes.
Expand Down

0 comments on commit ac0fc88

Please sign in to comment.