Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
MayModifyAttachments | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 1 |
__invoke | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
6 |
1 | <?php |
2 | /** @noinspection PhpUnhandledExceptionInspection */ |
3 | declare(strict_types=1); |
4 | |
5 | // TODO unit test |
6 | |
7 | use Psr\Http\Message\ResponseInterface; |
8 | use Slim\Exception\HttpForbiddenException; |
9 | use Slim\Exception\HttpNotFoundException; |
10 | use Slim\Http\ServerRequest as Request; |
11 | use Psr\Http\Server\RequestHandlerInterface as RequestHandler; |
12 | use Slim\Routing\RouteContext; |
13 | |
14 | class MayModifyAttachments { |
15 | function __invoke(Request $request, RequestHandler $handler): ResponseInterface { |
16 | /* @var $authToken AuthToken */ |
17 | $authToken = $request->getAttribute('AuthToken'); |
18 | |
19 | // TODo verify if it's the correct group! |
20 | |
21 | if ($authToken->getMode() !== 'monitor-group') { |
22 | throw new HttpForbiddenException($request, "Access Denied"); |
23 | } |
24 | return $handler->handle($request); |
25 | } |
26 | } |