Redirect to ReturnUrl when maintenance is disabled.
This commit is contained in:
parent
9de81c1281
commit
2c7842b3fa
|
|
@ -4,19 +4,12 @@ namespace App\Http\Middleware;
|
|||
|
||||
use Closure;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Illuminate\Contracts\Foundation\Application;
|
||||
|
||||
class PreventRequestsDuringMaintenance
|
||||
{
|
||||
protected $app;
|
||||
public function __construct(Application $app)
|
||||
{
|
||||
$this->app = $app;
|
||||
}
|
||||
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
if($this->app->isDownForMaintenance()) {
|
||||
if(app()->isDownForMaintenance()) {
|
||||
if(in_array('web', $request->route()->middleware()))
|
||||
{
|
||||
if($request->route()->uri() != 'maintenance')
|
||||
|
|
@ -29,6 +22,18 @@ class PreventRequestsDuringMaintenance
|
|||
->header('Content-Type', 'application/json; charset=utf-8');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if($request->route()->uri() == 'maintenance')
|
||||
{
|
||||
$returnUrl = $request->input('ReturnUrl');
|
||||
|
||||
if(!$returnUrl)
|
||||
$returnUrl = '/';
|
||||
|
||||
return redirect($returnUrl);
|
||||
}
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue