dev-think-one /
nova-laravel-filemanager
| 1 | <?php |
||
| 2 | |||
| 3 | namespace ThinkOne\NovaLaravelFilemanager\Http\Middleware; |
||
| 4 | |||
| 5 | use Laravel\Nova\Nova; |
||
| 6 | use ThinkOne\NovaLaravelFilemanager\NLFileManager; |
||
| 7 | |||
| 8 | class Authorize |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * Handle the incoming request. |
||
| 12 | * |
||
| 13 | * @param \Illuminate\Http\Request $request |
||
| 14 | * @param \Closure(\Illuminate\Http\Request):mixed $next |
||
| 15 | * @return \Illuminate\Http\Response |
||
| 16 | */ |
||
| 17 | public function handle($request, $next) |
||
| 18 | { |
||
| 19 | $tool = collect(Nova::registeredTools())->first([$this, 'matchesTool']); |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 20 | |||
| 21 | return optional($tool)->authorize($request) ? $next($request) : abort(403); |
||
|
0 ignored issues
–
show
Are you sure the usage of
abort(403) is correct as it seems to always return null.
This check looks for function or method calls that always return null and whose return value is used. class A
{
function getObject()
{
return null;
}
}
$a = new A();
if ($a->getObject()) {
The method The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes. Loading history...
|
|||
| 22 | } |
||
| 23 | |||
| 24 | /** |
||
| 25 | * Determine whether this tool belongs to the package. |
||
| 26 | * |
||
| 27 | * @param \Laravel\Nova\Tool $tool |
||
| 28 | * @return bool |
||
| 29 | */ |
||
| 30 | public function matchesTool($tool) |
||
| 31 | { |
||
| 32 | return $tool instanceof NLFileManager; |
||
| 33 | } |
||
| 34 | } |
||
| 35 |