mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-06-15 13:32:43 +01:00
Fixed redirect after two factor login for filament admin panel
This commit is contained in:
28
app/Extensions/Fortify/CustomTwoFactorLoginResponse.php
Normal file
28
app/Extensions/Fortify/CustomTwoFactorLoginResponse.php
Normal 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);
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ use App\Actions\Fortify\ResetUserPassword;
|
||||
use App\Actions\Fortify\UpdateUserPassword;
|
||||
use App\Actions\Fortify\UpdateUserProfileInformation;
|
||||
use App\Extensions\Fortify\CustomLoginResponse;
|
||||
use App\Extensions\Fortify\CustomTwoFactorLoginResponse;
|
||||
use App\Models\User;
|
||||
use Illuminate\Cache\RateLimiting\Limit;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -16,6 +17,7 @@ use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\RateLimiter;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Illuminate\Support\Str;
|
||||
use Laravel\Fortify\Contracts\TwoFactorLoginResponse;
|
||||
use Laravel\Fortify\Fortify;
|
||||
use Laravel\Fortify\Http\Responses\LoginResponse;
|
||||
|
||||
@@ -64,5 +66,6 @@ class FortifyServiceProvider extends ServiceProvider
|
||||
});
|
||||
|
||||
$this->app->instance(LoginResponse::class, new CustomLoginResponse());
|
||||
$this->app->instance(TwoFactorLoginResponse::class, new CustomTwoFactorLoginResponse());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ return [
|
||||
|
|
||||
*/
|
||||
|
||||
'name' => env('APP_NAME', 'Laravel'),
|
||||
'name' => env('APP_NAME', 'solidtime'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user