Back to Medusa

{metadata.title}

www/apps/resources/app/commerce-modules/customer/customer-accounts/page.mdx

2.14.22.6 KB
Original Source

export const metadata = { title: Customer Accounts, }

{metadata.title}

In this document, you’ll learn how registered and unregistered accounts are distinguished in the Medusa application.

<Note title="Looking for no-code docs?">

Refer to this Medusa Admin User Guide to learn how to manage customers using the dashboard.

</Note>

has_account Property

The Customer data model has a has_account property, which is a boolean that indicates whether a customer is registered.

When a guest customer places an order, a new Customer record is created with has_account set to false.

When this or another guest customer registers an account with the same email, a new Customer record is created with has_account set to true.


Email Uniqueness

The above behavior means that two Customer records may exist with the same email address. However, the main difference is the has_account property's value.

So, there can only be one guest customer (having has_account=false) and one registered customer (having has_account=true) with the same email address.


Customer Deletion and Email Reuse

When a merchant deletes a customer, the Customer record is soft-deleted, meaning it is not permanently removed from the database.

When using the Medusa Application with the Auth Module, possible confusion may arise in the following scenarios:

  1. An admin user is using the email address [email protected], and a customer tries to register with the same email address.
  2. An admin user has deleted a customer with the email address [email protected], and another customer tries to register with the same email address.

In these and similar scenarios, the customer trying to register will receive an error message indicating that the email address is already in use:

json
{
  "type": "unauthorized",
  "message": "Identity with email already exists"
}

To resolve this, you can amend the registration flow to:

  1. Retrieve the login token of the existing identity with the same email address.
  2. Use the login token when registering the new customer. This will not remove the existing identity but will allow the new customer to register with the same email address.

You can learn more about how to implement this flow in the following guides: