A cancelled request stops the e-mail two-factor code send #30

Closed
opened 2026-10-31 12:41:52 -04:00 by claude · 0 comments
Owner
  • Draft: REL-21
  • Priority: low (resource hygiene)
  • Agent: coder
  • Depends on: none
  • Decisions: none

Why

TwoFactorController.SendEmailCode() (src/dotnet/src/Ninlil.Web/Controllers/TwoFactorController.cs:270-302)
takes no cancellation token, so emailSender.SendAsync (which accepts one,
src/dotnet/src/Ninlil.Dns.Identity/Email/IEmailSender.cs:18-23) runs on after the client goes
away. It is the only action in the controllers without one. Its summary at :266 is also one
over-long unwrapped line.

What changes

Add CancellationToken stoppingToken and pass it to SendAsync; rewrap the summary. The
cooldown is acquired before the send (by design, TwoFactorEmailCodeCooldown.cs:12-13), so a
cancelled send still uses it: keep that and say so.

Acceptance

  • Web.Tests: a fake sender observes the request's token (red first).
  • OpenAPI unchanged (the token is not a parameter); OpenApiSnapshotTests green.

Source

d-design.md:393 (TwoFactorController.SendEmailCode cancellation, B3e-new-5).

- **Draft:** REL-21 - **Priority:** low (resource hygiene) - **Agent:** coder - **Depends on:** none - **Decisions:** none ### Why `TwoFactorController.SendEmailCode()` (`src/dotnet/src/Ninlil.Web/Controllers/TwoFactorController.cs:270-302`) takes no cancellation token, so `emailSender.SendAsync` (which accepts one, `src/dotnet/src/Ninlil.Dns.Identity/Email/IEmailSender.cs:18-23`) runs on after the client goes away. It is the only action in the controllers without one. Its summary at `:266` is also one over-long unwrapped line. ### What changes Add `CancellationToken stoppingToken` and pass it to `SendAsync`; rewrap the summary. The cooldown is acquired before the send (by design, `TwoFactorEmailCodeCooldown.cs:12-13`), so a cancelled send still uses it: keep that and say so. ### Acceptance - [ ] Web.Tests: a fake sender observes the request's token (red first). - [ ] OpenAPI unchanged (the token is not a parameter); `OpenApiSnapshotTests` green. ### Source `d-design.md:393` (`TwoFactorController.SendEmailCode` cancellation, B3e-new-5).
Sign in to join this conversation.
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
lantea-one/ninlil#30
No description provided.