Conditions | 8 |
Paths | 7 |
Total Lines | 18 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 11 |
CRAP Score | 8 |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
20 | 11 | public function handle($request, Closure $next) |
|
21 | { |
||
22 | // Check if user own tournament |
||
23 | |||
24 | 11 | if (Auth::check() && ($request->tournament != null || $request->tournamentId != null)) { |
|
25 | 10 | $userLogged = Auth::user(); |
|
26 | 10 | $tournaments = $userLogged->tournaments; |
|
27 | 10 | $tournament = $request->tournament; |
|
28 | 10 | if (!$tournament instanceof Tournament) { |
|
29 | 1 | $tournament = Tournament::where('slug', $tournament)->first(); |
|
30 | } |
||
31 | 10 | if ($tournament != null) { |
|
32 | 9 | if (!$tournaments->contains($tournament) && !$userLogged->isSuperAdmin()) { |
|
33 | 2 | throw new AuthorizationException(); |
|
34 | } |
||
35 | } |
||
36 | } |
||
37 | 10 | return $next($request); |
|
38 | } |
||
40 |