Alokai
You are reading the documentation for SDK v2, which is no longer the latest version. Switch to current

customerCreatePasswordResetToken

Method for creating a password reset token for a customer.

This method sends a POST request to the customerCreatePasswordResetToken endpoint of the Vue Storefront API Middleware. Default GraphQL query used by this method can be found here.

Signature

export declare function customerCreatePasswordResetToken<Res extends PartialCustomerCreatePasswordResetTokenResponse = CustomerCreatePasswordResetTokenResponse>(
	params: CustomerCreatePasswordResetTokenParams,
	options?: MethodOptions<CustomQuery<"customerCreatePasswordResetToken">>
): Promise<Res>;

Parameters

NameRequiredTypeDescription
paramsRequiredCustomerCreatePasswordResetTokenParamsParameter object which can be used with this method. Refer to its type definition to learn about possible properties.
optionsOptionalMethodOptions<CustomQuery<"customerCreatePasswordResetToken">>Options that can be passed to additionally configure the request or customize the logic in a plugin.

Returns

Returns a representation of the CustomerCreatePasswordResetTokenResponse.

Referenced Types

Examples

Creating a password reset token.

import { sdk } from '~/sdk.config.ts';
const { customerCreatePasswordResetToken } = await sdk.commerce.customerCreatePasswordResetToken(
 { email: 'john.doe@gmail.com', expose: true }
);

// Read the token value from the response
const token = customerCreatePasswordResetToken?.value;

Creating a custom GraphQL query for the method in middleware.config.js.

module.exports = {
 integrations: {
   ct: {
     // ...
     customQueries: {
       'customer-create-password-reset-token-custom-query': ({ variables, metadata }) => {
         return {
           variables,
           query: `
             mutation customerCreatePasswordResetToken($email: String!, $storeKey: KeyReferenceInput) {
             customerCreatePasswordResetToken(email: $email, storeKey: $storeKey) {
               ${metadata.fields}
             }
           }`
         };
       };
     }
   }
 }
};

Creates a password reset token using a custom query.

import { sdk } from '~/sdk.config.ts';
const customQuery = {
 customerCreatePasswordResetToken: 'customer-create-password-reset-token-custom-query',
 metadata: {
   fields: 'id customerId expiresAt value version createdAt lastModifiedAt'
 }
};

const { customerCreatePasswordResetToken } = await sdk.commerce.customerCreatePasswordResetToken(
 { email: TEST_USER_EMAIL, expose: true }, { customQuery }
);

// As a result, the response will contain only the fields specified in the custom query.

On this page