@@ 5-18 (lines=14) @@ | ||
2 | ||
3 | namespace App\Middleware; |
|
4 | ||
5 | class AuthMiddleware extends Middleware |
|
6 | { |
|
7 | public function __invoke($request, $response, $next) |
|
8 | { |
|
9 | if (!$this->container->auth->check()) { |
|
10 | $this->container->flash->addMessage('danger', 'Zaloguj się aby dostać się do tej podstrony'); |
|
11 | return $response->withRedirect($this->container->router->pathFor('auth.signin')); |
|
12 | } |
|
13 | ||
14 | $response = $next($request, $response); |
|
15 | return $response; |
|
16 | } |
|
17 | } |
|
18 |
@@ 7-20 (lines=14) @@ | ||
4 | ||
5 | use App\Middleware\Middleware; |
|
6 | ||
7 | class UserMiddleware extends Middleware |
|
8 | { |
|
9 | public function __invoke($request, $response, $next) |
|
10 | { |
|
11 | if (!$this->container->auth->check()) { |
|
12 | $this->container->flash->addMessage('danger', 'Zaloguj się aby dostać się do tej podstrony'); |
|
13 | return $response->withRedirect($this->container->router->pathFor('auth.signin')); |
|
14 | } |
|
15 | ||
16 | $response = $next($request, $response); |
|
17 | return $response; |
|
18 | } |
|
19 | } |
|
20 |