droboticflow/docs/account-deletion.md

1.9 KiB

Account deletion versus disabling

DELETE /api/users/{id} previously disabled an account but returned 204 without recording a deletion. Account management requests includeDisabled=true, so the account reappeared as disabled after refresh.

A successful deletion now first disables login, revokes sessions, releases unfinished claimed work and removes project membership. Only after those steps succeed does an optimistic update record deletedAt and deletedBy and erase the password hash. Directory responses always exclude deleted identities, including when disabled accounts are requested. Supplier directory counts therefore exclude them too. Ordinary disabling remains distinct and visible to account managers.

The identity, email and historical completed work remain for audit; the existing email-reservation contract is unchanged. Deleted identities cannot be edited or reactivated, including by stale store writes. Repeating a completed DELETE is idempotent. A cleanup failure leaves the account disabled with an error and permits retry; it does not falsely finalize deletion. Last-administrator and supplier permission protections continue to apply.

Do not backfill every disabled account as deleted: some were deliberately disabled. Completing a historical deletion requires an explicit target and verification. TestAccountDeleteLiveRepair is an opt-in, single-target operator repair; by default it only reads state. Applying requires exact email, name, supplier and an active same-scope ordinary administrator, and an already disabled non-administrator target. It writes a separate repair audit and invokes the normal deletion handler.

Regression coverage includes memory and standalone MongoDB, full directory exclusion, disabled-account visibility, supplier/project membership, pending task release, retained history, revoked sessions, stale-write rejection, repeat deletion and retry after cleanup failure.