feat(auth): harden authentication and add configurable two-factor support

This commit is contained in:
2026-07-31 03:12:46 +02:00
parent 235d5f646c
commit e47243f7dc
51 changed files with 2904 additions and 1359 deletions

View File

@@ -8,6 +8,16 @@ use Illuminate\Http\Request;
class TwoFactorChallenge
{
/**
* Determine whether the user must enroll in two-factor authentication.
*/
public function enrollmentRequiredFor(User $user): bool
{
return (bool) config('auth-ui.features.two_factor')
&& (bool) config('auth-ui.features.two_factor_required')
&& ! $user->hasEnabledTwoFactorAuthentication();
}
/**
* Determine whether the user must complete a two-factor challenge.
*/
@@ -25,6 +35,7 @@ class TwoFactorChallenge
$request->session()->put([
'login.id' => $user->getKey(),
'login.remember' => $remember,
'login.started_at' => now()->timestamp,
]);
$request->session()->regenerate();