You are reading the documentation for SDK v2, which is no longer the latest version. Switch to current
customerResetPassword
Method to reset the customer's password based on the token value.
This method sends a POST request to the customerResetPassword endpoint of the Vue Storefront API Middleware. It sends a request to commercetools GraphQL API to reset the customer's password based on the token value. Password Flow.
The default GraphQL query used by this method can be found here. You might also want to see the customerChangePassword method.
Signature
export declare function customerResetPassword<Res extends PartialCustomerResetPasswordResponse = CustomerResetPasswordResponse>(
params: CustomerResetPasswordParams,
options?: MethodOptions<CustomQuery<"customerResetPassword">>
): Promise<Res>;Parameters
| Name | Required | Type | Description |
|---|---|---|---|
params | Required | CustomerResetPasswordParams | Parameter object which can be used with this method. Refer to its type definition to learn about possible properties. |
options | Optional | MethodOptions<CustomQuery<"customerResetPassword">> | Options that can be passed to additionally configure the request or customize the logic in a plugin. |
Returns
Returns a representation of the CustomerResetPasswordResponse.
Referenced Types
- PartialCustomerResetPasswordResponse
- CustomerResetPasswordResponse
- CustomerResetPasswordParams
- MethodOptions
- CustomQuery
Examples
Generate password reset token, reset password and sign in with new password.
import { sdk } from '~/sdk.config.ts';
// Generate password reset token
const { customerCreatePasswordResetToken } = await sdk.commerce.customerCreatePasswordResetToken({
email: TEST_SIGN_UP_EMAIL,
expose: true
});
// Reset password
await sdk.commerce.customerResetPassword({
tokenValue: customerCreatePasswordResetToken.value,
newPassword: NEW_PASSWORD
});
// Sign in with new password
const { user } = await sdk.commerce.signIn({
email: 'your@email.com,
password: NEW_PASSWORD
});