Commit 43754d7
#3659 pinned the two ends of the 2FA failure budget — a wrong code is counted,
a correct one resets it. It stopped short of the transitions that make it a
LOCKOUT rather than a counter, which is the part that actually protects the
account. Three more assertions:
1. **The lock engages.** Spending the budget stamps `locked_until` in the
future. Reaching it means respecting two stacked budgets: better-auth allows
5 verifications per two-factor cookie (`beginAttempt(5)`) and 10 consecutive
failures per ACCOUNT (`accountLockout.maxFailedAttempts`). Only the second
touches the columns under test, so the loop takes a fresh challenge every 5
tries. The counter is asserted after every single failure, not just at the
end.
2. **The lock bites before the code is checked.** A locked account refuses even
a VALID TOTP with 429. Without this the "lockout" would just be a slower
guess loop.
3. **An expired lock clears itself.** better-auth clears it through a GUARDED
`incrementOne` — `where locked_until <= now`, `set { failedVerificationCount:
0, lockedUntil: null }`. That is the only place the ObjectQL adapter has to
handle `lte` against a datetime, so this covers the operator as much as the
columns: a driver mishandling it would leave the user locked out forever with
no error anywhere. The test ages the lock through the data engine because no
endpoint can — the default duration is 900s.
Test-only, and `@objectstack/dogfood` is private, hence the empty changeset.
Claude-Session: https://claude.ai/code/session_01UYLC8TfjzHGwatNxZKdX7H
Co-authored-by: Claude <noreply@anthropic.com>
1 parent adabaa8 commit 43754d7
2 files changed
Lines changed: 78 additions & 0 deletions
File tree
- .changeset
- packages/qa/dogfood/test
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
Lines changed: 74 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
213 | 213 | | |
214 | 214 | | |
215 | 215 | | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
216 | 290 | | |
0 commit comments