Conditions | 4 |
Paths | 3 |
Total Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
45 | public function __invoke(Request $request, Response $response, callable $next) |
||
46 | { |
||
47 | if (!$this->sentinel->check()) { |
||
48 | $this->flash->addMessage('error', 'You must be logged in to access this page!'); |
||
49 | |||
50 | return $response->withRedirect($this->router->pathFor('login')); |
||
51 | } elseif ($this->role && !$this->sentinel->inRole($this->role)) { |
||
52 | throw new AccessDeniedException($request, $response); |
||
53 | } |
||
54 | |||
55 | return $next($request, $response); |
||
56 | } |
||
57 | } |
||
58 |