#Identity with email already exists" can't resignup customer after deleting customer from admin panel

9 messages · Page 1 of 1 (latest)

tidal folio
#

Hello everyone,
I am trying to integrate auth into my nuxt 4 frontend using sdk (nuxt/medusa); initially didn't understand the auth flow to creating an account so tried to sign up with a few emails while I was unknowingly creating auth tokens by caling sdk.auth.register. When I finally realized I was supposed to make a second call to sdk.store.customer.create passing in the auth token from earlier into the headers. I kept getting Identity with email already exists.

Even when I finally realized what was going on and was able to create accounts, I still get thesame message when I delete an account and try to sign up with same email.

My questions are:

  1. How do i resolve the above issues?
  2. What would be the optimal way to integrate auth into my nuxt 4 frontend? I am new to vue/nuxt and have a feeling my current approach is hacky -- pinia store/local storage with route middleware .

Thank you in advance.

#

Identity with email already exists" can't resignup customer after deleting customer from admin panel

tidal folio
#
lastName?: string;phoneNumber?: string;}) {
  const medusa = useMedusa(); const toast = useToast(); this.isLoading = true;
this.error = null; let token;

      try {
        // Step 1: Try to register the identity
        try {
          token = await medusa.auth.register("customer", "emailpass", {
            email: payload.email,
            password: payload.password,
          });
        } catch (error: any) {
          const fetchError = error as { statusText?: string; message?: string};
if (fetchError.statusText !== "Unauthorized" || fetchError.message !== "Identity with email already exists") {
            throw new Error(fetchError.message || "Account creation failed");}
          const loginResponse = await medusa.auth
            .login("customer", "emailpass", {
              email: payload.email,
              password: payload.password,
            })
            .catch((e) => {
              throw new Error(e.message || "Login fallback failed");
            });
          token = loginResponse;
          if (!loginResponse || typeof loginResponse !== "string") {
            throw new Error(
              "Authentication requires unsupported additional steps."
            );
          }
        }
        const { customer } = await medusa.store.customer.create(
          {
            first_name: payload.firstName,
            last_name: payload.lastName,
            email: payload.email,
            phone: payload.phoneNumber,
          },
          {},
          { authorization: `Bearer ${token}` }
        );
        await navigateTo("/login");
      } catch (err: any) {
        this.error = err.message || "Signup failed";
        toast.add({
          title: "Signup failed",
          description: this.error || "Something went wrong",
          color: "error",
        });
        throw err;
      } finally {
        this.isLoading = false;
      }
    }```
royal halo
#

Unless things have been updated, "deleting" something in Medusa doesn't delete it from the database. It just flags it as "deleted". One solution is to manually delete that field from the database

tidal folio
#

Thank you for your reply, even though that is also a concern, but my main concern is not being able to signup that user after deleting them from the database. The auth flow to handle such case as described in the docs dosen't seem to work for some reason.

naive tangle
#

@tidal folio How did you delete you customer ?
You seem to have the email in the auth_identity table

tidal folio
naive tangle
#

In your first message you said that you delete an account and try to sign up again with the same email. How did you delete your account ? (with code, in the database, ...) ?