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

magento/devdocs#7366: GraphQL: Document password change mutations. Mutation: resetPassword. #7426

Merged
merged 3 commits into from
Jun 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/_data/toc/graphql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,10 @@ pages:
- label: revokeCustomerToken mutation
url: /graphql/mutations/revoke-customer-token.html

- label: resetPassword mutation
url: /graphql/mutations/reset-password.html
exclude_versions: ["2.3"]

- label: sendEmailToFriend mutation
url: /graphql/mutations/send-email-to-friend.html

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ contributor_name: Atwix
contributor_link: https://www.atwix.com/
---

The `requestPasswordResetEmail` mutation triggers the password reset email by the provided email address.
<!-- Use it to initiate the process to reset the registered customer's password before calling the [resetPassword]({{page.baseurl}}/graphql/mutations/reset-password.html) mutation. -->
The `requestPasswordResetEmail` mutation triggers the password reset email by the provided email address. Use it to initiate the process to reset the registered customer's password before calling the [resetPassword]({{page.baseurl}}/graphql/mutations/reset-password.html) mutation.

When the customer clicks the `Set a New Password` button, Magento sends an email to the customer that contains a URL for resetting their password.

Expand Down Expand Up @@ -72,4 +71,4 @@ Error | Description

## Related topics

<!-- [resetPassword mutation]({{page.baseurl}}/graphql/mutations/reset-password.html) -->
[resetPassword mutation]({{page.baseurl}}/graphql/mutations/reset-password.html)
70 changes: 70 additions & 0 deletions src/guides/v2.4/graphql/mutations/reset-password.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
---
group: graphql
title: resetPassword mutation
contributor_name: Atwix
contributor_link: https://www.atwix.com/
---

The `resetPassword` mutation resets customer password using a reset password token and the customer's email address. Use it to set a new password for the registered customer after calling the [requestPasswordResetEmail]({{page.baseurl}}/graphql/mutations/request-password-reset-email.html) mutation.

## Syntax

`mutation: {resetPassword(email: String!, resetPasswordToken: String!, newPassword: String!): Boolean}`

## Example usage

The following call sets a new customer password.

**Request:**

```graphql
mutation {
resetPassword(
email: "roni_cost@example.com",
resetPasswordToken: "gh80pkjGdsPyiXc0sUUXswX1uGN7crUr",
newPassword: "new_password"
)
}
```

**Response:**

```json
{
"data": {
"resetPassword": true
}
}
```

## Input arguments

The `resetPassword` mutation must contain the following arguments:

Argument | Type | Description
--- | --- | ---
`email` | String! | Specifies the customer account that needs a password reset
`resetPasswordToken` | String! | A runtime token. You can find it in the reset email URL (see [requestPasswordResetEmail]({{page.baseurl}}/graphql/mutations/request-password-reset-email.html) mutation) or in the `customer_entity`.`rp_token` database table.
`newPassword` | String! | The new password

{:.bs-callout-info}
The new password must satisfy the password policies set for the store.

## Output

The `resetPassword` mutation returns `true` if the request was successful. Otherwise, it returns `false`.

## Errors

Error | Description
--- | ---
`Cannot set the customer's password` | A general error message that appears on some internal system errors. The original error is logged and can be found in the Magento logs.
`newPassword must be specified` | The `newPassword` argument is empty.
`resetPasswordToken must be specified` | The `resetPasswordToken` argument is empty.
`The account is locked` | You cannot modify a locked customer account.
`The email address has an invalid format.` | The value provided in the `email` argument has an invalid format.
`You must specify an email address.` | The `email` argument is empty.

## Related topics

- [requestPasswordResetEmail mutation]({{page.baseurl}}/graphql/mutations/request-password-reset-email.html)