mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-08-18 05:02:14 +01:00
Fixed redirect after login for filament admin panel
This commit is contained in:
27
app/Extensions/Fortify/CustomLoginResponse.php
Normal file
27
app/Extensions/Fortify/CustomLoginResponse.php
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Extensions\Fortify;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Inertia\Inertia;
|
||||||
|
use Laravel\Fortify\Http\Responses\LoginResponse;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
|
class CustomLoginResponse extends LoginResponse
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 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()
|
||||||
|
? response()->json(['two_factor' => false])
|
||||||
|
: Inertia::location($redirectPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,6 +8,7 @@ use App\Actions\Fortify\CreateNewUser;
|
|||||||
use App\Actions\Fortify\ResetUserPassword;
|
use App\Actions\Fortify\ResetUserPassword;
|
||||||
use App\Actions\Fortify\UpdateUserPassword;
|
use App\Actions\Fortify\UpdateUserPassword;
|
||||||
use App\Actions\Fortify\UpdateUserProfileInformation;
|
use App\Actions\Fortify\UpdateUserProfileInformation;
|
||||||
|
use App\Extensions\Fortify\CustomLoginResponse;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Illuminate\Cache\RateLimiting\Limit;
|
use Illuminate\Cache\RateLimiting\Limit;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
@@ -16,6 +17,7 @@ use Illuminate\Support\Facades\RateLimiter;
|
|||||||
use Illuminate\Support\ServiceProvider;
|
use Illuminate\Support\ServiceProvider;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
use Laravel\Fortify\Fortify;
|
use Laravel\Fortify\Fortify;
|
||||||
|
use Laravel\Fortify\Http\Responses\LoginResponse;
|
||||||
|
|
||||||
class FortifyServiceProvider extends ServiceProvider
|
class FortifyServiceProvider extends ServiceProvider
|
||||||
{
|
{
|
||||||
@@ -60,5 +62,7 @@ class FortifyServiceProvider extends ServiceProvider
|
|||||||
RateLimiter::for('two-factor', function (Request $request) {
|
RateLimiter::for('two-factor', function (Request $request) {
|
||||||
return Limit::perMinute(5)->by($request->session()->get('login.id'));
|
return Limit::perMinute(5)->by($request->session()->get('login.id'));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$this->app->instance(LoginResponse::class, new CustomLoginResponse());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user