User Auth Functions
The User Auth drop-in provides API functions that enable you to programmatically control behavior, fetch data, and integrate with Adobe Commerce backend services.
| Function | Description |
|---|---|
confirmEmail | The confirmEmail function completes the customer activation process using the supplied customerEmail and customerConfirmationKey parameters. |
createCustomer | The createCustomer function creates a customer account based on the data supplied in the forms parameter. |
createCustomerAddress | The createCustomerAddress function defines a new customer address. |
getAttributesForm | The getAttributesForm function retrieves EAV attributes associated with customer and customer address frontend forms. |
getCustomerData | The getCustomerData function retrieves data about the customer represented by the value of the auth_dropin_user_token parameter. |
getCustomerToken | The getCustomerToken function handles the sign-in operation. |
getStoreConfig | The getStoreConfig function calls the storeConfig query to retrieve store configuration data.. |
requestPasswordResetEmail | The requestPasswordResetEmail function initiates the process of resetting a customer’s password. |
resendConfirmationEmail | The resendConfirmationEmail function resends the email confirmation to the customer using the supplied customerEmail parameter. |
resetPassword | The resetPassword function resets a customer’s password using the supplied email, resetPasswordToken, and newPassword parameters. |
revokeCustomerToken | The revokeCustomerToken function revokes the customer’s token and clears cookie. |
verifyToken | The verifyToken function checks the validity of the provided token and returns the authentication result.. |
confirmEmail
The confirmEmail function completes the customer activation process using the supplied customerEmail and customerConfirmationKey parameters. Adobe Commerce sends the confirmation key to the customer when they request to create an account. The function calls the confirmEmail mutation.
const confirmEmail = async ( { customerEmail, customerConfirmationKey,}: confirmEmailProps): Promise<confirmEmailResponse | undefined>| Parameter | Type | Req? | Description |
|---|---|---|---|
options | confirmEmailProps | Yes | See function signature above |
Returns
Returns confirmEmailResponse | undefined.
createCustomer
The createCustomer function creates a customer account based on the data supplied in the forms parameter. By default, the function calls the createCustomer mutation. If the apiVersion2 parameter is set to true, the function calls the createCustomerV2 mutation.
const createCustomer = async ( forms: Customer, apiVersion2: boolean): Promise<CustomerModel>| Parameter | Type | Req? | Description |
|---|---|---|---|
forms | Customer | Yes | See function signature above |
apiVersion2 | boolean | Yes | See function signature above |
Returns
Returns CustomerModel.
createCustomerAddress
The createCustomerAddress function defines a new customer address. The customer can subsequently designate the address for billing or shipping orders. The function calls the createCustomerAddress mutation.
const createCustomerAddress = async ( address: AddressFormProps): Promise<string>| Parameter | Type | Req? | Description |
|---|---|---|---|
address | AddressFormProps | Yes | See function signature above |
Returns
Returns string.
getAttributesForm
The getAttributesForm function retrieves EAV attributes associated with customer and customer address frontend forms. The function calls the attributesForm query.
const getAttributesForm = async ( formCode: string): Promise<AttributesFormModel[]>| Parameter | Type | Req? | Description |
|---|---|---|---|
formCode | string | Yes | See function signature above |
Returns
Returns AttributesFormModel[].
getCustomerData
The getCustomerData function retrieves data about the customer represented by the value of the auth_dropin_user_token parameter. The function calls the customer query.
const getCustomerData = async ( user_token: string): Promise<CustomerModel>| Parameter | Type | Req? | Description |
|---|---|---|---|
user_token | string | Yes | See function signature above |
Returns
Returns CustomerModel.
getCustomerToken
The getCustomerToken function handles the sign-in operation. It requires userName and password parameters and performs the following actions under the hood:
- Retrieves the customer token.
- Fetches customer data using the token.
- Sets the
auth_dropin_firstnameandauth_dropin_user_tokencookies. - Publishes an Adobe Client Data Layer (ACDL) event.
- Emits an “authenticated” event.
You can use the getCustomerToken function to build a custom authentication flow that remains fully integrated with other drop-in components. The function calls the generateCustomerToken mutation.
const getCustomerToken = async ( { email, password, translations, onErrorCallback, handleSetInLineAlertProps,}: getCustomerTokenProps): Promise<{ errorMessage: string; userName: string; userEmail: string;}>| Parameter | Type | Req? | Description |
|---|---|---|---|
options | getCustomerTokenProps | Yes | See function signature above |
Returns
Returns Promise<{ errorMessage: string; userName: string; userEmail: string; }>.
getStoreConfig
The getStoreConfig function calls the storeConfig query to retrieve store configuration data.
const getStoreConfig = async (): Promise<StoreConfigModel>Returns
Returns StoreConfigModel.
requestPasswordResetEmail
The requestPasswordResetEmail function initiates the process of resetting a customer’s password. The function calls the requestPasswordResetEmail mutation.
const requestPasswordResetEmail = async ( email: string): Promise<PasswordResetEmailModel>| Parameter | Type | Req? | Description |
|---|---|---|---|
email | string | Yes | See function signature above |
Returns
Returns PasswordResetEmailModel.
resendConfirmationEmail
The resendConfirmationEmail function resends the email confirmation to the customer using the supplied customerEmail parameter. The function calls the resendConfirmationEmail mutation, which is included in the Storefront Compatibility Package.
const resendConfirmationEmail = async ( customerEmail: string): Promise<resendConfirmationEmailResponse>| Parameter | Type | Req? | Description |
|---|---|---|---|
customerEmail | string | Yes | See function signature above |
Returns
Returns resendConfirmationEmailResponse.
resetPassword
The resetPassword function resets a customer’s password using the supplied email, resetPasswordToken, and newPassword parameters. The function calls the resetPassword mutation.
const resetPassword = async ( email: string, resetPasswordToken: string, newPassword: string): Promise<ResetPasswordModel>| Parameter | Type | Req? | Description |
|---|---|---|---|
email | string | Yes | See function signature above |
resetPasswordToken | string | Yes | See function signature above |
newPassword | string | Yes | See function signature above |
Returns
Returns ResetPasswordModel.
revokeCustomerToken
The revokeCustomerToken function revokes the customer’s token and clears cookie. It then publishes an ACDL event and emits an “authenticated” event. This API can also be used to build a custom sign-out flow that stays fully integrated with other drop-in components. The function calls the revokeCustomerToken mutation.
const revokeCustomerToken = async (): Promise<RevokeCustomerTokenModel>Returns
Returns RevokeCustomerTokenModel.
verifyToken
The verifyToken function checks the validity of the provided token and returns the authentication result.
const verifyToken = async ( authType = 'Authorization', type = 'Bearer'): Promise<any>Returns
Returns void.
Data Models
The following data models are used by functions in this drop-in.
CustomerModel
The CustomerModel object is returned by the following functions: createCustomer, getCustomerData.
interface CustomerModel { firstName: string; lastName: string; email: string; customAttributes?: Record<string, string>[]; errors?: { message: string }[];}PasswordResetEmailModel
The PasswordResetEmailModel object is returned by the following functions: requestPasswordResetEmail.
interface PasswordResetEmailModel { message: string | ''; success: boolean;}ResetPasswordModel
The ResetPasswordModel object is returned by the following functions: resetPassword.
interface ResetPasswordModel { message: string | ''; success: boolean;}RevokeCustomerTokenModel
The RevokeCustomerTokenModel object is returned by the following functions: revokeCustomerToken.
interface RevokeCustomerTokenModel { message: string | ''; success: boolean;}StoreConfigModel
The StoreConfigModel object is returned by the following functions: getStoreConfig.
interface StoreConfigModel { autocompleteOnStorefront: boolean; minLength: number; requiredCharacterClasses: number; createAccountConfirmation: boolean; customerAccessTokenLifetime: number;}