mirror of
https://github.com/InvoiceShelf/InvoiceShelf.git
synced 2026-04-13 00:07:21 +00:00
Laravel 13 upgrade, updates and fixes
This commit is contained in:
20
app/Http/Middleware/CustomerGuest.php
Normal file
20
app/Http/Middleware/CustomerGuest.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class CustomerGuest
|
||||
{
|
||||
/**
|
||||
* Guest-only routes for the customer guard (same behavior as {@see CustomerRedirectIfAuthenticated}).
|
||||
*
|
||||
* @param Closure(Request): (Response) $next
|
||||
*/
|
||||
public function handle(Request $request, Closure $next, ?string $guard = null): Response
|
||||
{
|
||||
return app(CustomerRedirectIfAuthenticated::class)->handle($request, $next, $guard);
|
||||
}
|
||||
}
|
||||
28
app/Http/Middleware/CustomerRedirectIfAuthenticated.php
Normal file
28
app/Http/Middleware/CustomerRedirectIfAuthenticated.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use App\Providers\RouteServiceProvider;
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class CustomerRedirectIfAuthenticated
|
||||
{
|
||||
/**
|
||||
* Redirect customers away from "guest" routes (e.g. login) when already authenticated.
|
||||
*
|
||||
* @param Closure(Request): (Response) $next
|
||||
*/
|
||||
public function handle(Request $request, Closure $next, ?string $guard = null): Response
|
||||
{
|
||||
$guard ??= 'customer';
|
||||
|
||||
if (Auth::guard($guard)->check()) {
|
||||
return redirect()->to(RouteServiceProvider::CUSTOMER_HOME);
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
@@ -2,9 +2,9 @@
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
|
||||
use Illuminate\Foundation\Http\Middleware\PreventRequestForgery as Middleware;
|
||||
|
||||
class VerifyCsrfToken extends Middleware
|
||||
class PreventRequestForgery extends Middleware
|
||||
{
|
||||
/**
|
||||
* Indicates whether the XSRF-TOKEN cookie should be set on the response.
|
||||
@@ -16,7 +16,7 @@ class VerifyCsrfToken extends Middleware
|
||||
/**
|
||||
* The URIs that should be excluded from CSRF verification.
|
||||
*
|
||||
* @var array
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $except = [
|
||||
'login',
|
||||
Reference in New Issue
Block a user