From c2e99b97cfb4496a740323bcfa89c030b2fd7a0f Mon Sep 17 00:00:00 2001 From: Jonathan Reinink Date: Wed, 29 Jul 2020 10:37:19 -0400 Subject: [PATCH] Update middleware --- app/Http/Middleware/Authenticate.php | 3 ++- .../Middleware/CheckForMaintenanceMode.php | 1 + app/Http/Middleware/EncryptCookies.php | 1 + .../Middleware/RedirectIfAuthenticated.php | 4 +++- app/Http/Middleware/TrustHosts.php | 20 +++++++++++++++++++ app/Http/Middleware/TrustProxies.php | 2 +- app/Http/Middleware/VerifyCsrfToken.php | 7 ------- 7 files changed, 28 insertions(+), 10 deletions(-) create mode 100644 app/Http/Middleware/TrustHosts.php diff --git a/app/Http/Middleware/Authenticate.php b/app/Http/Middleware/Authenticate.php index a4be5c5..09e6023 100644 --- a/app/Http/Middleware/Authenticate.php +++ b/app/Http/Middleware/Authenticate.php @@ -10,7 +10,7 @@ class Authenticate extends Middleware * Get the path the user should be redirected to when they are not authenticated. * * @param \Illuminate\Http\Request $request - * @return string + * @return string|null */ protected function redirectTo($request) { @@ -19,3 +19,4 @@ class Authenticate extends Middleware } } } + diff --git a/app/Http/Middleware/CheckForMaintenanceMode.php b/app/Http/Middleware/CheckForMaintenanceMode.php index 35b9824..ccb4ac1 100644 --- a/app/Http/Middleware/CheckForMaintenanceMode.php +++ b/app/Http/Middleware/CheckForMaintenanceMode.php @@ -15,3 +15,4 @@ class CheckForMaintenanceMode extends Middleware // ]; } + diff --git a/app/Http/Middleware/EncryptCookies.php b/app/Http/Middleware/EncryptCookies.php index 033136a..fec0e57 100644 --- a/app/Http/Middleware/EncryptCookies.php +++ b/app/Http/Middleware/EncryptCookies.php @@ -15,3 +15,4 @@ class EncryptCookies extends Middleware // ]; } + diff --git a/app/Http/Middleware/RedirectIfAuthenticated.php b/app/Http/Middleware/RedirectIfAuthenticated.php index e27860e..6990a60 100644 --- a/app/Http/Middleware/RedirectIfAuthenticated.php +++ b/app/Http/Middleware/RedirectIfAuthenticated.php @@ -2,6 +2,7 @@ namespace App\Http\Middleware; +use App\Providers\RouteServiceProvider; use Closure; use Illuminate\Support\Facades\Auth; @@ -18,9 +19,10 @@ class RedirectIfAuthenticated public function handle($request, Closure $next, $guard = null) { if (Auth::guard($guard)->check()) { - return redirect('/'); + return redirect(RouteServiceProvider::HOME); } return $next($request); } } + diff --git a/app/Http/Middleware/TrustHosts.php b/app/Http/Middleware/TrustHosts.php new file mode 100644 index 0000000..b0550cf --- /dev/null +++ b/app/Http/Middleware/TrustHosts.php @@ -0,0 +1,20 @@ +allSubdomainsOfApplicationUrl(), + ]; + } +} diff --git a/app/Http/Middleware/TrustProxies.php b/app/Http/Middleware/TrustProxies.php index 695ae0e..e794738 100644 --- a/app/Http/Middleware/TrustProxies.php +++ b/app/Http/Middleware/TrustProxies.php @@ -2,8 +2,8 @@ namespace App\Http\Middleware; -use Illuminate\Http\Request; use Fideloper\Proxy\TrustProxies as Middleware; +use Illuminate\Http\Request; class TrustProxies extends Middleware { diff --git a/app/Http/Middleware/VerifyCsrfToken.php b/app/Http/Middleware/VerifyCsrfToken.php index 324a166..0c13b85 100644 --- a/app/Http/Middleware/VerifyCsrfToken.php +++ b/app/Http/Middleware/VerifyCsrfToken.php @@ -6,13 +6,6 @@ use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware; class VerifyCsrfToken extends Middleware { - /** - * Indicates whether the XSRF-TOKEN cookie should be set on the response. - * - * @var bool - */ - protected $addHttpCookie = true; - /** * The URIs that should be excluded from CSRF verification. *