jeremykenedy /
laravel-auth
| 1 | <?php |
||||
| 2 | |||||
| 3 | namespace App\Http\Middleware; |
||||
| 4 | |||||
| 5 | use Auth; |
||||
| 6 | use Closure; |
||||
| 7 | use Illuminate\Http\Request; |
||||
| 8 | use Illuminate\Support\Facades\Log; |
||||
| 9 | use Illuminate\Support\Facades\Route; |
||||
| 10 | |||||
| 11 | class CheckCurrentUser |
||||
| 12 | { |
||||
| 13 | /** |
||||
| 14 | * Handle an incoming request. |
||||
| 15 | * |
||||
| 16 | * @param \Illuminate\Http\Request $request |
||||
| 17 | * @param \Closure $next |
||||
| 18 | * |
||||
| 19 | * @return mixed |
||||
| 20 | */ |
||||
| 21 | public function handle($request, Closure $next) |
||||
| 22 | { |
||||
| 23 | if (! $request->user()) { |
||||
| 24 | abort(403, 'Unauthorized action.'); |
||||
| 25 | } |
||||
| 26 | |||||
| 27 | return $next($request); |
||||
| 28 | } |
||||
| 29 | |||||
| 30 | public function terminate($request, $response) |
||||
|
0 ignored issues
–
show
The parameter
$request is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. Loading history...
|
|||||
| 31 | { |
||||
| 32 | $user = Auth::user(); |
||||
| 33 | $currentRoute = Route::currentRouteName(); |
||||
| 34 | Log::info('CheckCurrentUser middlware was used: '.$currentRoute.'. ', [$user]); |
||||
| 35 | } |
||||
| 36 | } |
||||
| 37 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.