Conditions | 4 |
Paths | 3 |
Total Lines | 12 |
Code Lines | 7 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
34 | public function __invoke(Request $request, Response $response, callable $next) |
||
35 | { |
||
36 | if (!$this->auth->check()) { |
||
37 | $this->flash->addMessage('error', 'You must be logged in to access this page!'); |
||
38 | |||
39 | return $response->withRedirect($this->router->pathFor('login')); |
||
40 | } elseif ($this->role && !$this->auth->inRole($this->role)) { |
||
41 | throw new AccessDeniedException(); |
||
42 | } |
||
43 | |||
44 | return $next($request, $response); |
||
45 | } |
||
46 | } |
||
47 |