Phase 0: Fundament für Inhaus
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 1m14s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 1m12s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 1m7s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 1m19s
CI / PHP 8.3 / mysql:8.0 (pull_request) Successful in 1m32s
CI / PHP 8.4 / mysql:8.0 (pull_request) Successful in 1m22s
CI / PHP 8.4 / mysql:8.4 (pull_request) Successful in 1m32s
CI / PHP 8.3 / mysql:8.4 (pull_request) Successful in 1m35s
CI / Build-Artefakte aktuell (pull_request) Failing after 1m7s
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 1m14s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 1m12s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 1m7s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 1m19s
CI / PHP 8.3 / mysql:8.0 (pull_request) Successful in 1m32s
CI / PHP 8.4 / mysql:8.0 (pull_request) Successful in 1m22s
CI / PHP 8.4 / mysql:8.4 (pull_request) Successful in 1m32s
CI / PHP 8.3 / mysql:8.4 (pull_request) Successful in 1m35s
CI / Build-Artefakte aktuell (pull_request) Failing after 1m7s
- Laravel 13 mit Filament 5 (Admin), Inertia 3 + Vue 3 + Vuetify 4 (Material 3) - Anmeldung über Fortify (Login, Passwort vergessen/ändern), keine Selbstregistrierung - Profil mit Profilbild (WebP in festen Größen), Personenseiten, Header mit Avatar-Menü - Material-3-Farbschema aus der Primärfarbe, hell/dunkel/System pro Person - Basis-Branding (Portalname, Logo, Primärfarbe) im Admin unter „Erscheinungsbild“ - Benutzerverwaltung im Admin, Zugang vorläufig über is_admin - vendor/ (ohne Dev-Pakete) und Frontend-Build mitversioniert, Dev-Pakete in vendor-dev/ - PHPUnit-Tests gegen MySQL/MariaDB, Forgejo-CI-Matrix, Docker-Entwicklungsumgebung - VERSION, CHANGELOG.md und CONTRIBUTING.md mit Release-Ablauf Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
7197eaebf2
commit
9c0f8de791
15771 changed files with 1564103 additions and 5 deletions
119
vendor/laravel/fortify/src/Actions/AttemptToAuthenticate.php
vendored
Normal file
119
vendor/laravel/fortify/src/Actions/AttemptToAuthenticate.php
vendored
Normal file
|
|
@ -0,0 +1,119 @@
|
|||
<?php
|
||||
|
||||
namespace Laravel\Fortify\Actions;
|
||||
|
||||
use Illuminate\Auth\Events\Failed;
|
||||
use Illuminate\Contracts\Auth\StatefulGuard;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Laravel\Fortify\Fortify;
|
||||
use Laravel\Fortify\LoginRateLimiter;
|
||||
|
||||
class AttemptToAuthenticate
|
||||
{
|
||||
/**
|
||||
* The guard implementation.
|
||||
*
|
||||
* @var \Illuminate\Contracts\Auth\StatefulGuard
|
||||
*/
|
||||
protected $guard;
|
||||
|
||||
/**
|
||||
* The login rate limiter instance.
|
||||
*
|
||||
* @var \Laravel\Fortify\LoginRateLimiter
|
||||
*/
|
||||
protected $limiter;
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\StatefulGuard $guard
|
||||
* @param \Laravel\Fortify\LoginRateLimiter $limiter
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(StatefulGuard $guard, LoginRateLimiter $limiter)
|
||||
{
|
||||
$this->guard = $guard;
|
||||
$this->limiter = $limiter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param callable $next
|
||||
* @return mixed
|
||||
*
|
||||
* @throws ValidationException
|
||||
*/
|
||||
public function handle($request, $next)
|
||||
{
|
||||
if (Fortify::$authenticateUsingCallback) {
|
||||
return $this->handleUsingCustomCallback($request, $next);
|
||||
}
|
||||
|
||||
if ($this->guard->attempt(
|
||||
$request->only(Fortify::username(), 'password'),
|
||||
$request->boolean('remember'))
|
||||
) {
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
$this->throwFailedAuthenticationException($request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to authenticate using a custom callback.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param callable $next
|
||||
* @return mixed
|
||||
*
|
||||
* @throws ValidationException
|
||||
*/
|
||||
protected function handleUsingCustomCallback($request, $next)
|
||||
{
|
||||
$user = call_user_func(Fortify::$authenticateUsingCallback, $request);
|
||||
|
||||
if (! $user) {
|
||||
$this->fireFailedEvent($request);
|
||||
|
||||
return $this->throwFailedAuthenticationException($request);
|
||||
}
|
||||
|
||||
$this->guard->login($user, $request->boolean('remember'));
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Throw a failed authentication validation exception.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return void
|
||||
*
|
||||
* @throws \Illuminate\Validation\ValidationException
|
||||
*/
|
||||
protected function throwFailedAuthenticationException($request)
|
||||
{
|
||||
$this->limiter->increment($request);
|
||||
|
||||
throw ValidationException::withMessages([
|
||||
Fortify::username() => [trans('auth.failed')],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fire the failed authentication attempt event with the given arguments.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return void
|
||||
*/
|
||||
protected function fireFailedEvent($request)
|
||||
{
|
||||
event(new Failed($this->guard?->name ?? config('fortify.guard'), null, [
|
||||
Fortify::username() => $request->{Fortify::username()},
|
||||
'password' => $request->password,
|
||||
]));
|
||||
}
|
||||
}
|
||||
27
vendor/laravel/fortify/src/Actions/CanonicalizeUsername.php
vendored
Normal file
27
vendor/laravel/fortify/src/Actions/CanonicalizeUsername.php
vendored
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
namespace Laravel\Fortify\Actions;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use Laravel\Fortify\Fortify;
|
||||
|
||||
class CanonicalizeUsername
|
||||
{
|
||||
/**
|
||||
* Handle the incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param callable $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, $next)
|
||||
{
|
||||
if ($request->has(Fortify::username())) {
|
||||
$request->merge([
|
||||
Fortify::username() => Str::lower($request->{Fortify::username()}),
|
||||
]);
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
26
vendor/laravel/fortify/src/Actions/CompletePasswordReset.php
vendored
Normal file
26
vendor/laravel/fortify/src/Actions/CompletePasswordReset.php
vendored
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
|
||||
namespace Laravel\Fortify\Actions;
|
||||
|
||||
use Illuminate\Auth\Events\PasswordReset;
|
||||
use Illuminate\Contracts\Auth\StatefulGuard;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class CompletePasswordReset
|
||||
{
|
||||
/**
|
||||
* Complete the password reset process for the given user.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\StatefulGuard $guard
|
||||
* @param mixed $user
|
||||
* @return void
|
||||
*/
|
||||
public function __invoke(StatefulGuard $guard, $user)
|
||||
{
|
||||
$user->setRememberToken(Str::random(60));
|
||||
|
||||
$user->save();
|
||||
|
||||
event(new PasswordReset($user));
|
||||
}
|
||||
}
|
||||
43
vendor/laravel/fortify/src/Actions/ConfirmPassword.php
vendored
Normal file
43
vendor/laravel/fortify/src/Actions/ConfirmPassword.php
vendored
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
|
||||
namespace Laravel\Fortify\Actions;
|
||||
|
||||
use Illuminate\Contracts\Auth\StatefulGuard;
|
||||
use Laravel\Fortify\Fortify;
|
||||
|
||||
class ConfirmPassword
|
||||
{
|
||||
/**
|
||||
* Confirm that the given password is valid for the given user.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\StatefulGuard $guard
|
||||
* @param mixed $user
|
||||
* @param string|null $password
|
||||
* @return bool
|
||||
*/
|
||||
public function __invoke(StatefulGuard $guard, $user, ?string $password = null)
|
||||
{
|
||||
$username = Fortify::username();
|
||||
|
||||
return is_null(Fortify::$confirmPasswordsUsingCallback) ? $guard->validate([
|
||||
$username => $user->{$username},
|
||||
'password' => $password,
|
||||
]) : $this->confirmPasswordUsingCustomCallback($user, $password);
|
||||
}
|
||||
|
||||
/**
|
||||
* Confirm the user's password using a custom callback.
|
||||
*
|
||||
* @param mixed $user
|
||||
* @param string|null $password
|
||||
* @return bool
|
||||
*/
|
||||
protected function confirmPasswordUsingCustomCallback($user, ?string $password = null)
|
||||
{
|
||||
return call_user_func(
|
||||
Fortify::$confirmPasswordsUsingCallback,
|
||||
$user,
|
||||
$password
|
||||
);
|
||||
}
|
||||
}
|
||||
55
vendor/laravel/fortify/src/Actions/ConfirmTwoFactorAuthentication.php
vendored
Normal file
55
vendor/laravel/fortify/src/Actions/ConfirmTwoFactorAuthentication.php
vendored
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
<?php
|
||||
|
||||
namespace Laravel\Fortify\Actions;
|
||||
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Laravel\Fortify\Contracts\TwoFactorAuthenticationProvider;
|
||||
use Laravel\Fortify\Events\TwoFactorAuthenticationConfirmed;
|
||||
use Laravel\Fortify\Fortify;
|
||||
|
||||
class ConfirmTwoFactorAuthentication
|
||||
{
|
||||
/**
|
||||
* The two factor authentication provider.
|
||||
*
|
||||
* @var \Laravel\Fortify\Contracts\TwoFactorAuthenticationProvider
|
||||
*/
|
||||
protected $provider;
|
||||
|
||||
/**
|
||||
* Create a new action instance.
|
||||
*
|
||||
* @param \Laravel\Fortify\Contracts\TwoFactorAuthenticationProvider $provider
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(TwoFactorAuthenticationProvider $provider)
|
||||
{
|
||||
$this->provider = $provider;
|
||||
}
|
||||
|
||||
/**
|
||||
* Confirm the two factor authentication configuration for the user.
|
||||
*
|
||||
* @param mixed $user
|
||||
* @param string $code
|
||||
* @return void
|
||||
*
|
||||
* @throws ValidationException
|
||||
*/
|
||||
public function __invoke($user, $code)
|
||||
{
|
||||
if (empty($user->two_factor_secret) ||
|
||||
empty($code) ||
|
||||
! $this->provider->verify(Fortify::currentEncrypter()->decrypt($user->two_factor_secret), $code)) {
|
||||
throw ValidationException::withMessages([
|
||||
'code' => [__('The provided two factor authentication code was invalid.')],
|
||||
])->errorBag('confirmTwoFactorAuthentication');
|
||||
}
|
||||
|
||||
$user->forceFill([
|
||||
'two_factor_confirmed_at' => now(),
|
||||
])->save();
|
||||
|
||||
TwoFactorAuthenticationConfirmed::dispatch($user);
|
||||
}
|
||||
}
|
||||
31
vendor/laravel/fortify/src/Actions/DisableTwoFactorAuthentication.php
vendored
Normal file
31
vendor/laravel/fortify/src/Actions/DisableTwoFactorAuthentication.php
vendored
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
namespace Laravel\Fortify\Actions;
|
||||
|
||||
use Laravel\Fortify\Events\TwoFactorAuthenticationDisabled;
|
||||
use Laravel\Fortify\Fortify;
|
||||
|
||||
class DisableTwoFactorAuthentication
|
||||
{
|
||||
/**
|
||||
* Disable two factor authentication for the user.
|
||||
*
|
||||
* @param mixed $user
|
||||
* @return void
|
||||
*/
|
||||
public function __invoke($user)
|
||||
{
|
||||
if (! is_null($user->two_factor_secret) ||
|
||||
! is_null($user->two_factor_recovery_codes) ||
|
||||
! is_null($user->two_factor_confirmed_at)) {
|
||||
$user->forceFill([
|
||||
'two_factor_secret' => null,
|
||||
'two_factor_recovery_codes' => null,
|
||||
] + (Fortify::confirmsTwoFactorAuthentication() || ! is_null($user->two_factor_confirmed_at) ? [
|
||||
'two_factor_confirmed_at' => null,
|
||||
] : []))->save();
|
||||
|
||||
TwoFactorAuthenticationDisabled::dispatch($user);
|
||||
}
|
||||
}
|
||||
}
|
||||
53
vendor/laravel/fortify/src/Actions/EnableTwoFactorAuthentication.php
vendored
Normal file
53
vendor/laravel/fortify/src/Actions/EnableTwoFactorAuthentication.php
vendored
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
<?php
|
||||
|
||||
namespace Laravel\Fortify\Actions;
|
||||
|
||||
use Illuminate\Support\Collection;
|
||||
use Laravel\Fortify\Contracts\TwoFactorAuthenticationProvider;
|
||||
use Laravel\Fortify\Events\TwoFactorAuthenticationEnabled;
|
||||
use Laravel\Fortify\Fortify;
|
||||
use Laravel\Fortify\RecoveryCode;
|
||||
|
||||
class EnableTwoFactorAuthentication
|
||||
{
|
||||
/**
|
||||
* The two factor authentication provider.
|
||||
*
|
||||
* @var \Laravel\Fortify\Contracts\TwoFactorAuthenticationProvider
|
||||
*/
|
||||
protected $provider;
|
||||
|
||||
/**
|
||||
* Create a new action instance.
|
||||
*
|
||||
* @param \Laravel\Fortify\Contracts\TwoFactorAuthenticationProvider $provider
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(TwoFactorAuthenticationProvider $provider)
|
||||
{
|
||||
$this->provider = $provider;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable two factor authentication for the user.
|
||||
*
|
||||
* @param mixed $user
|
||||
* @param bool $force
|
||||
* @return void
|
||||
*/
|
||||
public function __invoke($user, $force = false)
|
||||
{
|
||||
if (empty($user->two_factor_secret) || $force === true) {
|
||||
$secretLength = (int) config('fortify-options.two-factor-authentication.secret-length', 16);
|
||||
|
||||
$user->forceFill([
|
||||
'two_factor_secret' => Fortify::currentEncrypter()->encrypt($this->provider->generateSecretKey($secretLength)),
|
||||
'two_factor_recovery_codes' => Fortify::currentEncrypter()->encrypt(json_encode(Collection::times(8, function () {
|
||||
return RecoveryCode::generate();
|
||||
})->all())),
|
||||
])->save();
|
||||
|
||||
TwoFactorAuthenticationEnabled::dispatch($user);
|
||||
}
|
||||
}
|
||||
}
|
||||
46
vendor/laravel/fortify/src/Actions/EnsureLoginIsNotThrottled.php
vendored
Normal file
46
vendor/laravel/fortify/src/Actions/EnsureLoginIsNotThrottled.php
vendored
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
|
||||
namespace Laravel\Fortify\Actions;
|
||||
|
||||
use Illuminate\Auth\Events\Lockout;
|
||||
use Laravel\Fortify\Contracts\LockoutResponse;
|
||||
use Laravel\Fortify\LoginRateLimiter;
|
||||
|
||||
class EnsureLoginIsNotThrottled
|
||||
{
|
||||
/**
|
||||
* The login rate limiter instance.
|
||||
*
|
||||
* @var \Laravel\Fortify\LoginRateLimiter
|
||||
*/
|
||||
protected $limiter;
|
||||
|
||||
/**
|
||||
* Create a new class instance.
|
||||
*
|
||||
* @param \Laravel\Fortify\LoginRateLimiter $limiter
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(LoginRateLimiter $limiter)
|
||||
{
|
||||
$this->limiter = $limiter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param callable $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, $next)
|
||||
{
|
||||
if (! $this->limiter->tooManyAttempts($request)) {
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
event(new Lockout($request));
|
||||
|
||||
return app(LockoutResponse::class);
|
||||
}
|
||||
}
|
||||
28
vendor/laravel/fortify/src/Actions/GenerateNewRecoveryCodes.php
vendored
Normal file
28
vendor/laravel/fortify/src/Actions/GenerateNewRecoveryCodes.php
vendored
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
namespace Laravel\Fortify\Actions;
|
||||
|
||||
use Illuminate\Support\Collection;
|
||||
use Laravel\Fortify\Events\RecoveryCodesGenerated;
|
||||
use Laravel\Fortify\Fortify;
|
||||
use Laravel\Fortify\RecoveryCode;
|
||||
|
||||
class GenerateNewRecoveryCodes
|
||||
{
|
||||
/**
|
||||
* Generate new recovery codes for the user.
|
||||
*
|
||||
* @param mixed $user
|
||||
* @return void
|
||||
*/
|
||||
public function __invoke($user)
|
||||
{
|
||||
$user->forceFill([
|
||||
'two_factor_recovery_codes' => Fortify::currentEncrypter()->encrypt(json_encode(Collection::times(8, function () {
|
||||
return RecoveryCode::generate();
|
||||
})->all())),
|
||||
])->save();
|
||||
|
||||
RecoveryCodesGenerated::dispatch($user);
|
||||
}
|
||||
}
|
||||
44
vendor/laravel/fortify/src/Actions/PrepareAuthenticatedSession.php
vendored
Normal file
44
vendor/laravel/fortify/src/Actions/PrepareAuthenticatedSession.php
vendored
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
|
||||
namespace Laravel\Fortify\Actions;
|
||||
|
||||
use Laravel\Fortify\LoginRateLimiter;
|
||||
|
||||
class PrepareAuthenticatedSession
|
||||
{
|
||||
/**
|
||||
* The login rate limiter instance.
|
||||
*
|
||||
* @var \Laravel\Fortify\LoginRateLimiter
|
||||
*/
|
||||
protected $limiter;
|
||||
|
||||
/**
|
||||
* Create a new class instance.
|
||||
*
|
||||
* @param \Laravel\Fortify\LoginRateLimiter $limiter
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(LoginRateLimiter $limiter)
|
||||
{
|
||||
$this->limiter = $limiter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param callable $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, $next)
|
||||
{
|
||||
if ($request->hasSession()) {
|
||||
$request->session()->regenerate();
|
||||
}
|
||||
|
||||
$this->limiter->clear($request);
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
160
vendor/laravel/fortify/src/Actions/RedirectIfTwoFactorAuthenticatable.php
vendored
Normal file
160
vendor/laravel/fortify/src/Actions/RedirectIfTwoFactorAuthenticatable.php
vendored
Normal file
|
|
@ -0,0 +1,160 @@
|
|||
<?php
|
||||
|
||||
namespace Laravel\Fortify\Actions;
|
||||
|
||||
use Illuminate\Auth\Events\Failed;
|
||||
use Illuminate\Contracts\Auth\StatefulGuard;
|
||||
use Illuminate\Support\Timebox;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Laravel\Fortify\Contracts\RedirectsIfTwoFactorAuthenticatable;
|
||||
use Laravel\Fortify\Events\TwoFactorAuthenticationChallenged;
|
||||
use Laravel\Fortify\Fortify;
|
||||
use Laravel\Fortify\LoginRateLimiter;
|
||||
use Laravel\Fortify\TwoFactorAuthenticatable;
|
||||
|
||||
class RedirectIfTwoFactorAuthenticatable implements RedirectsIfTwoFactorAuthenticatable
|
||||
{
|
||||
/**
|
||||
* The guard implementation.
|
||||
*
|
||||
* @var \Illuminate\Contracts\Auth\StatefulGuard
|
||||
*/
|
||||
protected $guard;
|
||||
|
||||
/**
|
||||
* The login rate limiter instance.
|
||||
*
|
||||
* @var \Laravel\Fortify\LoginRateLimiter
|
||||
*/
|
||||
protected $limiter;
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\StatefulGuard $guard
|
||||
* @param \Laravel\Fortify\LoginRateLimiter $limiter
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(StatefulGuard $guard, LoginRateLimiter $limiter)
|
||||
{
|
||||
$this->guard = $guard;
|
||||
$this->limiter = $limiter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param callable $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, $next)
|
||||
{
|
||||
$user = $this->validateCredentials($request);
|
||||
|
||||
if (Fortify::confirmsTwoFactorAuthentication()) {
|
||||
if (optional($user)->two_factor_secret &&
|
||||
! is_null(optional($user)->two_factor_confirmed_at) &&
|
||||
in_array(TwoFactorAuthenticatable::class, class_uses_recursive($user))) {
|
||||
return $this->twoFactorChallengeResponse($request, $user);
|
||||
} else {
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
|
||||
if (optional($user)->two_factor_secret &&
|
||||
in_array(TwoFactorAuthenticatable::class, class_uses_recursive($user))) {
|
||||
return $this->twoFactorChallengeResponse($request, $user);
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to validate the incoming credentials.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
protected function validateCredentials($request)
|
||||
{
|
||||
if (Fortify::$authenticateUsingCallback) {
|
||||
return tap(call_user_func(Fortify::$authenticateUsingCallback, $request), function ($user) use ($request) {
|
||||
if (! $user) {
|
||||
$this->fireFailedEvent($request);
|
||||
|
||||
$this->throwFailedAuthenticationException($request);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$provider = $this->guard->getProvider();
|
||||
|
||||
return (new Timebox())->call(function () use ($request, $provider) {
|
||||
return tap($provider->retrieveByCredentials($request->only(Fortify::username(), 'password')), function ($user) use ($provider, $request) {
|
||||
if (! $user || ! $provider->validateCredentials($user, ['password' => $request->password])) {
|
||||
$this->fireFailedEvent($request, $user);
|
||||
|
||||
$this->throwFailedAuthenticationException($request);
|
||||
}
|
||||
|
||||
if (config('hashing.rehash_on_login', true) && method_exists($provider, 'rehashPasswordIfRequired')) {
|
||||
$provider->rehashPasswordIfRequired($user, ['password' => $request->password]);
|
||||
}
|
||||
});
|
||||
}, 200000);
|
||||
}
|
||||
|
||||
/**
|
||||
* Throw a failed authentication validation exception.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return void
|
||||
*
|
||||
* @throws \Illuminate\Validation\ValidationException
|
||||
*/
|
||||
protected function throwFailedAuthenticationException($request)
|
||||
{
|
||||
$this->limiter->increment($request);
|
||||
|
||||
throw ValidationException::withMessages([
|
||||
Fortify::username() => [trans('auth.failed')],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fire the failed authentication attempt event with the given arguments.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Illuminate\Contracts\Auth\Authenticatable|null $user
|
||||
* @return void
|
||||
*/
|
||||
protected function fireFailedEvent($request, $user = null)
|
||||
{
|
||||
event(new Failed($this->guard?->name ?? config('fortify.guard'), $user, [
|
||||
Fortify::username() => $request->{Fortify::username()},
|
||||
'password' => $request->password,
|
||||
]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the two factor authentication enabled response.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param mixed $user
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
protected function twoFactorChallengeResponse($request, $user)
|
||||
{
|
||||
$request->session()->put([
|
||||
'login.id' => $user->getKey(),
|
||||
'login.remember' => $request->boolean('remember'),
|
||||
]);
|
||||
|
||||
TwoFactorAuthenticationChallenged::dispatch($user);
|
||||
|
||||
return $request->wantsJson()
|
||||
? response()->json(['two_factor' => true])
|
||||
: redirect()->route('two-factor.login');
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue