2FA setup required: the window of existing accounts starts once, at the first start after the upgrade

Owner's decision: for accounts that exist before the upgrade the 72 hours
count from the first start after it. The code already stamped them then; this
adds the tests that the moment is written once per account (a restart, two
instances starting at once, edits and logins do not move it; 71 h after it setup
is open, 73 h after it the account is blocked) and says so in the docs.

After the rebase on 1.16.5: tests that the setup-required notice and the stale
import-map notice both stand above the screen and never replace the code form,
and that requireSetup, safeBack and guard switch independently.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-11-24 18:56:07 +01:00
co-authored by Claude Fable 5.2
parent 5d44ac3135
commit 9d2ab43438
7 changed files with 191 additions and 6 deletions
+8
View File
@@ -460,6 +460,14 @@ now to set it up…`. From that moment they can only set TOTP up; after 72 hours
administrator reopens setup. **Before upgrading a live site, run `pnpm exec ipal-doctor --url <site>`** (accounts
without 2FA) and have those accounts set TOTP up, or remove the ones nobody uses.
That starting moment is **written once**, on each such account (`totpSetupFrom`), by the start that first finds
the account without one. Later starts, redeploys and further instances find nothing left to do (the log line
appears on that first start only), and editing the account or logging in does not move it — so a redeploy never
hands out another 72 hours. Only an administrator's reset / "Reopen setup" opens a new window. An existing
account that **has** TOTP gets no start; if its TOTP is removed later, its window starts then. On Postgres /
SQLite "the first start" means the first start **with the migration applied**: before that there is no column
to write to, the log warns, and those accounts have no time limit yet.
```ts
twoFactor: {
issuer: 'Company Name',