Make email and phone unique per business, not platform-wide #5
Reference in New Issue
Block a user
Delete Branch "fix/per-business-identity"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Email and phone were unique across the whole platform, so one person could not work for two businesses, and signup and staff creation told anyone whether an email or phone was registered anywhere.
⚠️ Deploy step
Run this straight after deploying:
It flags the existing platform-operator account(s) and swaps the old platform-wide unique indexes (
email_1,phoneNumber_1) for per-business ones. Until it runs, operators cannot open the Platform console and a second business cannot reuse an email. Safe to re-run.What changes
platformAdminflag on the account as well as the email inPLATFORM_ADMIN_EMAILS. With per-business emails, an email match alone would have let any owner create a staff account with the operator's email in their own business and open the cross-tenant console. The flag is only set bynpm run seedand the migration, never through the app; removing the email from the env list still revokes access.Testing
npm test: 65 tests pass, 9 new intests/identity.test.ts:email_1andphoneNumber_1; second run changed nothing; afterwards the same email in a second business is accepted and a duplicate within one business refused.Details:
docs/PILOT_READINESS.md, "People in more than one business".🤖 Generated with Claude Code