auth/mail: Magic-Link-2FA (M1) + Mailversand über die Queue

- Magic-Link-Login übergibt bei aktiviertem 2FA an die 2FA-Challenge,
  statt sie zu umgehen (M1).
- Bestätigungs-/Benachrichtigungs-Mails (Kontakt, Recht, Kündigung,
  Widerruf, Magic-Link) laufen als ShouldQueue+afterCommit über die Queue,
  damit die Response nicht am SMTP-Roundtrip hängt.

Hinweis: Der Queue-Worker muss im Betrieb laufen und überwacht werden, da
fristrelevante Bestätigungen darüber zugestellt werden (siehe
Betriebsüberwachung).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Kevin Adametz 2026-07-14 13:49:21 +00:00
parent 8f517e993d
commit fe1525b9ff
20 changed files with 135 additions and 60 deletions

View file

@ -34,7 +34,7 @@ test('the termination confirmation page renders the § 312k form with the hub sh
->toContain('Publisher · Hub');
});
test('an ordinary termination is persisted and both mails are sent immediately', function () {
test('an ordinary termination is persisted and both mails are queued after persistence', function () {
/** @var TestCase $this */
Mail::fake();
config()->set('domains.domains.pressekonto.brand.contact_email', 'kontakt@pressekonto.de');
@ -62,8 +62,8 @@ test('an ordinary termination is persisted and both mails are sent immediately',
expect($request->status)->toBe('open');
// § 312k Abs. 4 BGB: sofortige automatische Zugangsbestätigung.
Mail::assertSent(TerminationRequestReceived::class, fn (TerminationRequestReceived $mail) => $mail->hasTo('paula@example.test'));
Mail::assertSent(TerminationRequestSubmitted::class, fn (TerminationRequestSubmitted $mail) => $mail->hasTo('kontakt@pressekonto.de'));
Mail::assertQueued(TerminationRequestReceived::class, fn (TerminationRequestReceived $mail) => $mail->hasTo('paula@example.test'));
Mail::assertQueued(TerminationRequestSubmitted::class, fn (TerminationRequestSubmitted $mail) => $mail->hasTo('kontakt@pressekonto.de'));
});
test('an extraordinary termination requires a reason', function () {
@ -78,7 +78,7 @@ test('an extraordinary termination requires a reason', function () {
])->assertSessionHasErrorsIn('termination', ['reason']);
expect(TerminationRequest::query()->count())->toBe(0);
Mail::assertNothingSent();
Mail::assertNothingOutgoing();
$this->post('https://pressekonto.test/de/kuendigung', [
'kind' => 'ausserordentlich',
@ -123,7 +123,7 @@ test('termination validation errors land in the termination error bag', function
])->assertSessionHasErrorsIn('termination', ['kind', 'name', 'email', 'terminate_mode']);
expect(TerminationRequest::query()->count())->toBe(0);
Mail::assertNothingSent();
Mail::assertNothingOutgoing();
});
test('honeypot submissions are silently accepted without persisting or mailing', function () {
@ -139,5 +139,5 @@ test('honeypot submissions are silently accepted without persisting or mailing',
])->assertSessionHas('termination-status');
expect(TerminationRequest::query()->count())->toBe(0);
Mail::assertNothingSent();
Mail::assertNothingOutgoing();
});