mirror of
https://github.com/storytold/artcraft-services.git
synced 2026-11-19 08:53:03 +01:00
## What was wrong `script/database/copy_user_account.py` moves an account's email and password onto another account and says it ends the source account's sessions. The revocation `UPDATE` had `LIMIT 10` and also matched sessions that were already deleted. If the source account had more than ten session rows, some live sessions could survive the transfer and keep working, because session lookups accept any row with `deleted_at IS NULL` and `expires_at > NOW()`. ## What changed - The revocation `UPDATE` has no row limit and only targets live sessions (`deleted_at IS NULL`), so the timestamps on rows that were already deleted stay as they were. - After the update, the script counts the source's remaining live sessions inside the same transaction. If any are left, it raises, and the existing handler rolls back. - The confirmation preview counts live sessions, and the docstring lists the revocation step. ## Blast radius This only affects the oncall script that an operator runs by hand. No service code changed. Session lookups do not use a cache (`crates/lib/actix_artcraft/src/sessions` reads MySQL directly), so nothing else needs invalidating. ## Checks - Run: `python3 -m py_compile script/database/copy_user_account.py` - Not run: running the script against a database (it needs a live MySQL and secrets.toml). Addresses CodeRabbit security findings (CWE-613). <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **Bug Fixes** * Account-copy operations now stop and roll back if any live source sessions remain, rather than committing an incomplete transfer. <!-- end of auto-generated comment: release notes by coderabbit.ai -->