Delete a User (re-signup)

CLI to remove a user from Cognito and DynamoDB so they can sign up again

Why this exists

Google sign-in (and email/password signup) refuses an address that already has a Cognito user. To re-test Gmail login without creating a new Gmail account, delete the existing auth user first.

apps/zooly-auth/scripts/delete-user-by-email.sh is a CLI that uses the AWS CLI (--profile zooly) to find that email and remove it from auth.

What it deletes

For the given email it removes:

  1. Cognito — every matching user: native email/password and Google-federated (Google_… / google_…)
  2. DynamoDB (zooly-auth-identities) — identity records keyed by that Cognito sub, records whose cognito_sub matches, and guest records whose guest_email matches

After that, the same address can sign up again (email/password or Continue with Google).

This is not the duplicate-merge cleanup. To unite two identities that should stay one person, use Identity Fragmentation (unite-duplicate-identities.ts) instead.

Prerequisites

  • AWS CLI configured with the zooly profile
  • jq
  • Defaults match prod auth (us-east-1, pool us-east-1_tvlpQoJAn, table zooly-auth-identities). Override with env if needed (see below).

Usage

From the repo root:

# 1. Preview — always run this first
./apps/zooly-auth/scripts/delete-user-by-email.sh you@gmail.com --dry-run

# 2. Delete (retype the email to confirm)
./apps/zooly-auth/scripts/delete-user-by-email.sh you@gmail.com

# Skip the prompt (scripts / CI)
./apps/zooly-auth/scripts/delete-user-by-email.sh you@gmail.com --yes

Same via npm:

npm run delete-user --workspace zooly-auth -- you@gmail.com --dry-run
npm run delete-user --workspace zooly-auth -- you@gmail.com

Flags

FlagMeaning
--dry-runPrint matching Cognito users and DynamoDB identities; delete nothing
--yes / -ySkip the “type the email again” confirmation
-h / --helpUsage

Without --yes, a TTY prompt asks you to type the email again. Non-interactive runs without --yes exit without deleting.

Environment overrides

Optional. Unset values use the prod auth defaults.

VariableDefault
AWS_PROFILEzooly
AWS_REGION / COGNITO_REGION / DYNAMODB_REGIONus-east-1
COGNITO_USER_POOL_IDus-east-1_tvlpQoJAn
DYNAMODB_TABLE_IDENTITIESzooly-auth-identities

Example for a different pool:

COGNITO_USER_POOL_ID=us-east-1_xxxxx \
  ./apps/zooly-auth/scripts/delete-user-by-email.sh you@gmail.com --dry-run

After deletion

Sign in again at auth.zooly.ai (or local auth) with Google or email/password. Cognito should treat the address as new and create a fresh user + DynamoDB identity.

Existing merch orders/sessions stamped with the old user_id stay in Postgres under that old id. If you need history remapped onto a surviving identity, that is a different flow — see Identity Fragmentation.