CLI to remove a user from Cognito and DynamoDB so they can sign up again
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.
This is a destructive AWS operation. Always run --dry-run first. It does not delete merch/Postgres rows — only Cognito users and DynamoDB identity records.
For the given email it removes:
Google_… / google_…)zooly-auth-identities) — identity records keyed by that Cognito sub, records whose cognito_sub matches, and guest records whose guest_email matchesAfter 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.
zooly profilejqus-east-1, pool us-east-1_tvlpQoJAn, table zooly-auth-identities). Override with env if needed (see below).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
| Flag | Meaning |
|---|---|
--dry-run | Print matching Cognito users and DynamoDB identities; delete nothing |
--yes / -y | Skip the “type the email again” confirmation |
-h / --help | Usage |
Without --yes, a TTY prompt asks you to type the email again. Non-interactive runs without --yes exit without deleting.
Optional. Unset values use the prod auth defaults.
| Variable | Default |
|---|---|
AWS_PROFILE | zooly |
AWS_REGION / COGNITO_REGION / DYNAMODB_REGION | us-east-1 |
COGNITO_USER_POOL_ID | us-east-1_tvlpQoJAn |
DYNAMODB_TABLE_IDENTITIES | zooly-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
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.