Fixed redirect after two factor login for filament admin panel

This commit is contained in:
Constantin Graf
2024-05-02 16:20:52 +02:00
parent 0f898130e0
commit 97751b3499
3 changed files with 32 additions and 1 deletions

View File

@@ -0,0 +1,28 @@
<?php
declare(strict_types=1);
namespace App\Extensions\Fortify;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Inertia\Inertia;
use Laravel\Fortify\Contracts\TwoFactorLoginResponse as TwoFactorLoginResponseContract;
use Symfony\Component\HttpFoundation\Response;
class CustomTwoFactorLoginResponse implements TwoFactorLoginResponseContract
{
/**
* Create an HTTP response that represents the object.
*
* @param Request $request
*/
public function toResponse($request): Response
{
$redirectPath = session()->pull('url.intended', route('dashboard', [], false));
return $request->wantsJson()
? new JsonResponse('', 204)
: Inertia::location($redirectPath);
}
}