Skip to content

Commit b4a27f3

Browse files
committed
Disable Laravel Debugbar on all StageFront routes
Including Throttle error page.
1 parent 2fdbfa3 commit b4a27f3

File tree

4 files changed

+31
-17
lines changed

4 files changed

+31
-17
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ Extra translations are always welcome. :)
124124

125125
## Laravel Debugbar
126126

127-
Laravel Debugbar will be disabled on the StageFront login page automatically if you use it in your project. This will hide any potential sensitive data from the public, if by accident Debugbar is running on your staging site.
127+
Laravel Debugbar will be disabled on the StageFront routes automatically if you use it in your project. This will hide any potential sensitive data from the public, if by accident Debugbar is running on your staging site. You can remove this by editing the `middleware` option in the [configuration file](#publish-configuration-file).
128128

129129
## Testing
130130

config/stagefront.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,12 @@
8383
* Since StageFront uses the session, we definitely require
8484
* the web middleware group. But you can change it if needed.
8585
*
86-
* Default: ['web']
86+
* Default: ['web', \CodeZero\StageFront\Middleware\DisableLaravelDebugbar::class]
8787
*/
88-
'middleware' => ['web'],
88+
'middleware' => [
89+
'web',
90+
\CodeZero\StageFront\Middleware\DisableLaravelDebugbar::class,
91+
],
8992

9093
/**
9194
* The following URLs will be ignored by StageFront.

src/Controllers/StageFrontController.php

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ public function create()
2727
];
2828
}
2929

30-
$this->disableLaravelDebugbar();
31-
3230
return view('stagefront::login', compact('liveSite'));
3331
}
3432

@@ -51,16 +49,4 @@ public function store()
5149

5250
return redirect()->intended('/');
5351
}
54-
55-
/**
56-
* Disable Laravel Debugbar if it is loaded.
57-
*
58-
* @return void
59-
*/
60-
protected function disableLaravelDebugbar()
61-
{
62-
if (class_exists('\Debugbar')) {
63-
\Debugbar::disable();
64-
}
65-
}
6652
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
namespace CodeZero\StageFront\Middleware;
4+
5+
use Closure;
6+
7+
class DisableLaravelDebugbar
8+
{
9+
/**
10+
* Handle an incoming request.
11+
*
12+
* @param \Illuminate\Http\Request $request
13+
* @param \Closure $next
14+
*
15+
* @return mixed
16+
*/
17+
public function handle($request, Closure $next)
18+
{
19+
if (class_exists('\Debugbar')) {
20+
\Debugbar::disable();
21+
}
22+
23+
return $next($request);
24+
}
25+
}

0 commit comments

Comments
 (0)