refactor(auth): tighten trait visibility, return type, @mixin

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
feat/v1-foundation
boban 2026-06-20 15:28:36 +02:00
parent 1fef9e61fe
commit 0765293123
1 changed files with 6 additions and 3 deletions

View File

@ -7,18 +7,21 @@ use App\Services\WebauthnService;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\RateLimiter;
use Illuminate\Validation\ValidationException;
use Livewire\Component;
/**
* Shared 2FA-challenge plumbing for the TOTP/key view and the backup-only view: the
* pending-user resolver, the brute-force buckets (ONE shared counter set across both
* views), and the login success tail. Centralising it guarantees both views hit the
* same rate limit and complete login identically.
*
* @mixin Component
*/
trait CompletesTwoFactorChallenge
{
protected ?User $pendingUser = null;
private ?User $pendingUser = null;
protected bool $pendingResolved = false;
private bool $pendingResolved = false;
/** The pending 2FA user, resolved once per request from the session. */
protected function pendingUser(): ?User
@ -91,7 +94,7 @@ trait CompletesTwoFactorChallenge
}
/** Log the verified pending user in and finish the challenge (shared success tail). */
protected function completeLogin(User $user)
protected function completeLogin(User $user): mixed
{
$remember = (bool) session('2fa.remember');
session()->forget(['2fa.user', '2fa.remember']);