Repository navigation
users.previous_accounts and users.merge - #4
Merged
Merged
Conversation
Someone deleted who signs in again gets a fresh account (a new id). users.previous_accounts(user_id) lists the person's earlier, deleted accounts in the app, and users.merge(user_id, from_id) brings one into the live account: roles, resource roles, passkeys, MFA methods and unused backup codes move over, the live account wins on meta and attributes, history stays on the old account. A second merge raises APIError (422, already_merged). Unit tests against the fake API; README entry. Live tests: a test identity signed in, given a role and deleted signs in again to a new id (the old one is 404), previous_accounts lists the old account, merge moves the role and a second merge is already_merged; someone deactivated and then deleted gets 403 account_deactivated at sign-in. 55 passed against scute-api-v2 v24.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this adds
Someone deleted who signs in again now gets a fresh account (a new id). Their earlier account stays deleted, with its history. Two secret-key calls cover it:
scute.users.previous_accounts(user_id)lists the person's earlier, deleted accounts in the app, newest first. Each hasid,status,created_at,deleted_at,merged_into(once merged), and what it still holds:rolesandpasskeyscounts, andmfa_methods.scute.users.merge(user_id, from_id)brings one of those into the live account.{user_id, merged, moved: {...}}. Merging the same account again raisesAPIError(422,already_merged).Both are typed and documented, with a README entry. The README also says that someone deactivated and then deleted can't sign in again (403,
account_deactivated).Tests
already_merged, and checks that the POST isn't retried.previous_accountslists the old account with its role.mergemoves the role, and the check now allows what the role grants.merged_into, and a second merge isalready_merged.account_deactivated, andfind_by_identifierreturnsNone.Results
mypy --strict src tests/live: clean.pytest -m liveagainst scute-api-v2 v24: 55 passed, 0 failed. It used seven sign-ins plus one refused.