From b98ff8d04cafaaacc91c7803a2337cb3aadd6c1e Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Sun, 22 Mar 2020 09:58:14 +0800 Subject: [PATCH 1/2] [5.x] Avoid throwing exception on production. The risk of running Dusk in production revolve assigning unsecure routing to assist testing with Dusk. Signed-off-by: Mior Muhammad Zaki --- src/DuskServiceProvider.php | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/src/DuskServiceProvider.php b/src/DuskServiceProvider.php index d4e1aed0c..7d8c18982 100644 --- a/src/DuskServiceProvider.php +++ b/src/DuskServiceProvider.php @@ -15,20 +15,22 @@ class DuskServiceProvider extends ServiceProvider */ public function boot() { - Route::get('/_dusk/login/{userId}/{guard?}', [ - 'middleware' => 'web', - 'uses' => 'Laravel\Dusk\Http\Controllers\UserController@login', - ]); + if (! $this->app->environment('production')) { + Route::get('/_dusk/login/{userId}/{guard?}', [ + 'middleware' => 'web', + 'uses' => 'Laravel\Dusk\Http\Controllers\UserController@login', + ]); - Route::get('/_dusk/logout/{guard?}', [ - 'middleware' => 'web', - 'uses' => 'Laravel\Dusk\Http\Controllers\UserController@logout', - ]); + Route::get('/_dusk/logout/{guard?}', [ + 'middleware' => 'web', + 'uses' => 'Laravel\Dusk\Http\Controllers\UserController@logout', + ]); - Route::get('/_dusk/user/{guard?}', [ - 'middleware' => 'web', - 'uses' => 'Laravel\Dusk\Http\Controllers\UserController@user', - ]); + Route::get('/_dusk/user/{guard?}', [ + 'middleware' => 'web', + 'uses' => 'Laravel\Dusk\Http\Controllers\UserController@user', + ]); + } } /** @@ -40,10 +42,6 @@ public function boot() */ public function register() { - if ($this->app->environment('production')) { - throw new Exception('It is unsafe to run Dusk in production.'); - } - if ($this->app->runningInConsole()) { $this->commands([ Console\InstallCommand::class, From 50764f9320841bd7e74802a50461694e1855ec64 Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Sun, 22 Mar 2020 10:01:11 +0800 Subject: [PATCH 2/2] Remove unused exception. Signed-off-by: Mior Muhammad Zaki --- src/DuskServiceProvider.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/DuskServiceProvider.php b/src/DuskServiceProvider.php index 7d8c18982..d969ba1dd 100644 --- a/src/DuskServiceProvider.php +++ b/src/DuskServiceProvider.php @@ -2,7 +2,6 @@ namespace Laravel\Dusk; -use Exception; use Illuminate\Support\Facades\Route; use Illuminate\Support\ServiceProvider;