Skip to content

Commit

Permalink
wip - upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
gandesc committed Oct 12, 2020
1 parent e3f5a70 commit 1de165d
Show file tree
Hide file tree
Showing 57 changed files with 1,131 additions and 1,554 deletions.
4 changes: 3 additions & 1 deletion app/Http/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ class Kernel extends HttpKernel
{
protected $middleware = [
\LaravelEnso\Core\Http\Middleware\AuthorizationCookie::class,
// \App\Http\Middleware\TrustHosts::class,
\App\Http\Middleware\TrustProxies::class,
\Fruitcake\Cors\HandleCors::class,
\App\Http\Middleware\CheckForMaintenanceMode::class,
\App\Http\Middleware\PreventRequestsDuringMaintenance::class,
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
\App\Http\Middleware\TrimStrings::class,
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
Expand All @@ -31,6 +32,7 @@ class Kernel extends HttpKernel
'api' => [
\LaravelEnso\Core\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
\Illuminate\Routing\Middleware\SubstituteBindings::class,
'throttle:api',
],
];

Expand Down
12 changes: 0 additions & 12 deletions app/Http/Middleware/CheckForMaintenanceMode.php

This file was deleted.

17 changes: 17 additions & 0 deletions app/Http/Middleware/PreventRequestsDuringMaintenance.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace App\Http\Middleware;

use Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance as Middleware;

class PreventRequestsDuringMaintenance extends Middleware
{
/**
* The URIs that should be reachable while maintenance mode is enabled.
*
* @var array
*/
protected $except = [
//
];
}
10 changes: 7 additions & 3 deletions app/Http/Middleware/RedirectIfAuthenticated.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@

class RedirectIfAuthenticated
{
public function handle($request, Closure $next, $guard = null)
public function handle($request, Closure $next, ...$guards)
{
if (Auth::guard($guard)->check()) {
return redirect(RouteServiceProvider::HOME);
$guards = empty($guards) ? [null] : $guards;

foreach ($guards as $guard) {
if (Auth::guard($guard)->check()) {
return redirect(RouteServiceProvider::HOME);
}
}

return $next($request);
Expand Down
20 changes: 20 additions & 0 deletions app/Http/Middleware/TrustHosts.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace App\Http\Middleware;

use Illuminate\Http\Middleware\TrustHosts as Middleware;

class TrustHosts extends Middleware
{
/**
* Get the host patterns that should be trusted.
*
* @return array
*/
public function hosts()
{
return [
$this->allSubdomainsOfApplicationUrl(),
];
}
}
36 changes: 34 additions & 2 deletions app/Providers/RouteServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,35 @@

namespace App\Providers;

use Illuminate\Cache\RateLimiting\Limit;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\RateLimiter;
use Illuminate\Support\Facades\Route;

class RouteServiceProvider extends ServiceProvider
{
public const HOME = '/';

protected $namespace = 'App\Http\Controllers';
/**
* The controller namespace for the application.
*
* When present, controller route declarations will automatically be prefixed with this namespace.
*
* @var string|null
*/
// protected $namespace = 'App\\Http\\Controllers';

public function map()
/**
* Define your route model bindings, pattern filters, etc.
*
* @return void
*/
public function boot()
{
$this->configureRateLimiting();

$this->mapApiRoutes();

$this->mapWebRoutes();
Expand All @@ -32,4 +50,18 @@ protected function mapApiRoutes()
->namespace($this->namespace)
->group(base_path('routes/api.php'));
}

/**
* Configure the rate limiters for the application.
*
* @return void
*/
protected function configureRateLimiting()
{
RateLimiter::for('api', function (Request $request) {
return App::runningUnitTests()
? Limit::none()
: Limit::perMinute(1000);
});
}
}
Loading

0 comments on commit 1de165d

Please sign in to comment.