mirror of
https://github.com/bitbaum/petvity.git
synced 2026-12-04 12:27:37 +01:00
petvity-cron-reset-demo failed with HTTP 500 on 12 Nov after a run of successes. The reset deleted the demo user, then spent a bcrypt hash before re-inserting it under its pinned id, so for a few hundred milliseconds every two hours the demo account did not exist; a demo sign-in in that gap could leave a demo row of its own, and the pinned insert then failed on the unique email. Any step failing half-way also left no demo account until the next run. - Hash first; delete and reseed inside one transaction, so a visitor sees the old demo or the new one, never none, and a failed run rolls back. - Delete by the pinned id or the demo email, so a stray demo row is cleared instead of colliding with the insert. Tests: the reset hashes before it deletes, runs inside a transaction, and rolls back when a step fails.