Passed
Push — feature/permissions-management ( 41e93d )
by
unknown
11:22 queued 04:04
created

Permission   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
dl 0
loc 15
rs 10
c 1
b 0
f 0
wmc 7

1 Method

Rating   Name   Duplication   Size   Complexity  
B handle() 0 13 7
1
<?php
2
3
namespace A17\Twill\Http\Middleware;
4
5
use Auth;
6
use Closure;
7
use Illuminate\Http\Request;
8
9
class Permission
10
{
11
    public function handle(Request $request, Closure $next)
12
    {
13
        if (config('twill.enabled.permissions-management') && !Auth::user()->isSuperAdmin()) {
0 ignored issues
show
Bug introduced by
The method isSuperAdmin() does not exist on Illuminate\Contracts\Auth\Authenticatable. It seems like you code against a sub-type of Illuminate\Contracts\Auth\Authenticatable such as Illuminate\Foundation\Auth\User. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

13
        if (config('twill.enabled.permissions-management') && !Auth::user()->/** @scrutinizer ignore-call */ isSuperAdmin()) {
Loading history...
14
            if (config('twill.support_subdomain_admin_routing') && $activeSubdomain = config('twill.active_subdomain')) {
15
                foreach(Auth::user()->groups as $group) {
0 ignored issues
show
Bug introduced by
Accessing groups on the interface Illuminate\Contracts\Auth\Authenticatable suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
16
                    if (in_array($activeSubdomain, $group->subdomains_access)) {
17
                        return $next($request);
18
                    }
19
                };
20
                abort(403);
21
            }
22
        }
23
        return $next($request);
24
    }
25
}
26