Alokai

customerCreatePasswordResetToken

Create a password reset token for a customer.

By default, it uses the customerChangeMyPasswordDefaultQuery GraphQL query

Signature

declare function customerCreatePasswordResetToken(
	context: CommercetoolsIntegrationContext,
	email: string,
	expose?: false,
	customQuery?: CustomQuery
): Promise<any | CustomerCreatePasswordResetTokenResponse>;

Parameters

NameRequiredTypeDescription
contextRequiredCommercetoolsIntegrationContext
emailRequiredstring
exposeOptionalfalse
customQueryOptionalCustomQuery

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(
  'john.doe@gmail.com',
  true
);

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

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

export const 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(
  TEST_USER_EMAIL,
  true
  customQuery
);

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

On this page