Skip to content

Commit

Permalink
fix: fix webauthn login (#7222)
Browse files Browse the repository at this point in the history
  • Loading branch information
asbiin committed Apr 8, 2024
1 parent 9dbe256 commit c8cc301
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 23 deletions.
9 changes: 2 additions & 7 deletions app/Actions/Fortify/RedirectIfTwoFactorAuthenticatable.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ class RedirectIfTwoFactorAuthenticatable
{
/**
* Create a new action instance.
*
* @return void
*/
public function __construct(
protected StatefulGuard $guard,
Expand All @@ -27,10 +25,8 @@ public function __construct(

/**
* Handle the incoming request.
*
* @return mixed
*/
public function handle(Request $request, Closure $next)
public function handle(Request $request, Closure $next): mixed
{
$user = $this->validateCredentials($request);

Expand Down Expand Up @@ -59,7 +55,6 @@ protected function validateCredentials(Request $request): ?User
/**
* Throw a failed authentication validation exception.
*
*
* @throws \Illuminate\Validation\ValidationException
*/
protected function throwFailedAuthenticationException(Request $request): void
Expand Down Expand Up @@ -91,7 +86,7 @@ protected function twoFactorChallengeResponse(Request $request, ?User $user)
{
$request->session()->put([
'login.id' => $user->getKey(),
'login.remember' => $request->filled('remember'),
'login.remember' => $request->boolean('remember'),
]);

TwoFactorAuthenticationChallenged::dispatch($user);
Expand Down
9 changes: 0 additions & 9 deletions app/Providers/FortifyServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace App\Providers;

use App\Actions\Fortify\CreateNewUser;
use App\Actions\Fortify\RedirectIfTwoFactorAuthenticatable;
use App\Actions\Fortify\ResetUserPassword;
use App\Actions\Fortify\TwoFactorChallengeView;
use App\Actions\Fortify\UpdateUserPassword;
Expand All @@ -14,8 +13,6 @@
use Illuminate\Http\Request;
use Illuminate\Support\Facades\RateLimiter;
use Illuminate\Support\ServiceProvider;
use Laravel\Fortify\Actions\AttemptToAuthenticate;
use Laravel\Fortify\Actions\PrepareAuthenticatedSession;
use Laravel\Fortify\Fortify;

class FortifyServiceProvider extends ServiceProvider
Expand All @@ -37,12 +34,6 @@ public function register()
*/
public function boot()
{
Fortify::authenticateThrough(fn () => [
RedirectIfTwoFactorAuthenticatable::class,
AttemptToAuthenticate::class,
PrepareAuthenticatedSession::class,
]);

Fortify::loginView(fn ($request) => (new LoginController())($request));
Fortify::confirmPasswordsUsing(fn ($user, ?string $password = null) => $user->password
? app(StatefulGuard::class)->validate([
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"php": "^8.2",
"ext-fileinfo": "*",
"asbiin/laravel-sentry-tunnel": "^2.0",
"asbiin/laravel-webauthn": "^4.0",
"asbiin/laravel-webauthn": "^4.4",
"codezero/laravel-localizer": "^3.0",
"doctrine/dbal": "^3.6",
"guzzlehttp/guzzle": "^7.4",
Expand Down
12 changes: 6 additions & 6 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions config/fortify.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,4 +142,11 @@
]),
],

'pipelines' => [
'login' => [
\App\Actions\Fortify\RedirectIfTwoFactorAuthenticatable::class,
\Laravel\Fortify\Actions\AttemptToAuthenticate::class,
\Laravel\Fortify\Actions\PrepareAuthenticatedSession::class,
],
],
];

0 comments on commit c8cc301

Please sign in to comment.