Skip to content

Commit b98ff8d

Browse files
committed
[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 <[email protected]>
1 parent da28590 commit b98ff8d

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

src/DuskServiceProvider.php

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,22 @@ class DuskServiceProvider extends ServiceProvider
1515
*/
1616
public function boot()
1717
{
18-
Route::get('/_dusk/login/{userId}/{guard?}', [
19-
'middleware' => 'web',
20-
'uses' => 'Laravel\Dusk\Http\Controllers\UserController@login',
21-
]);
18+
if (! $this->app->environment('production')) {
19+
Route::get('/_dusk/login/{userId}/{guard?}', [
20+
'middleware' => 'web',
21+
'uses' => 'Laravel\Dusk\Http\Controllers\UserController@login',
22+
]);
2223

23-
Route::get('/_dusk/logout/{guard?}', [
24-
'middleware' => 'web',
25-
'uses' => 'Laravel\Dusk\Http\Controllers\UserController@logout',
26-
]);
24+
Route::get('/_dusk/logout/{guard?}', [
25+
'middleware' => 'web',
26+
'uses' => 'Laravel\Dusk\Http\Controllers\UserController@logout',
27+
]);
2728

28-
Route::get('/_dusk/user/{guard?}', [
29-
'middleware' => 'web',
30-
'uses' => 'Laravel\Dusk\Http\Controllers\UserController@user',
31-
]);
29+
Route::get('/_dusk/user/{guard?}', [
30+
'middleware' => 'web',
31+
'uses' => 'Laravel\Dusk\Http\Controllers\UserController@user',
32+
]);
33+
}
3234
}
3335

3436
/**
@@ -40,10 +42,6 @@ public function boot()
4042
*/
4143
public function register()
4244
{
43-
if ($this->app->environment('production')) {
44-
throw new Exception('It is unsafe to run Dusk in production.');
45-
}
46-
4745
if ($this->app->runningInConsole()) {
4846
$this->commands([
4947
Console\InstallCommand::class,

0 commit comments

Comments
 (0)