resetPassword
Changes the customer's password to the new password value in the call using the reset password token that was returned from the requestResetPassword method.
This method communicates with the resetPassword endpoint of the Vue Storefront API Middleware. In turn, it receives data from the resetPassword or the Reset Customer Password endpoints exposed by SCAPI / OCAPI depending on the middleware configuration.
This process requires the customer to have received a reset token over a secure channel, and to have been presented with a form to enter a new password, which also has the token as e.g. a hidden field and adds it to the request.
If using OCAPI, the customer login must also be provided.
If using SCAPI, the code verifier that was used in the original token generate request must also be provided. This will be passed to the onPasswordResetTokenGenerated callback.
Signature
export declare function resetPassword(
props: ResetPasswordParams
): Promise<ResetPasswordResult>;Parameters
| Name | Required | Type | Description |
|---|---|---|---|
props | Required | ResetPasswordParams | Parameter object which can be used with this method. Refer to its type definition to learn about possible properties. |
Returns
Status object for the password reset process,
Referenced Types
ResetPasswordParamsResetPasswordResult
Examples
Create a new password for a given customer through OCAPI.
import { sdk } from '~/sdk.config.ts';
const { success } = await $sdk.commerce.resetPassword({
token: form.querySelector('[type="hidden"][name="token"]).value,
login: form.querySelector('[type="hidden"][name="login"]).value,
newPassword: form.querySelector('[type="password"][name="newPassword"]).value
})Create a new password for a given customer through SCAPI.
import { sdk } from '~/sdk.config.ts';
const { success } = await $sdk.commerce.resetPassword({
token: form.querySelector('[type="hidden"][name="token"]).value,
codeVerifier: form.querySelector('[type="hidden"][name="verifier"]).value,
newPassword: form.querySelector('[type="password"][name="newPassword"]).value
})