Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
MayModifyAttachments
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 1
 __invoke
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
6
1<?php
2/** @noinspection PhpUnhandledExceptionInspection */
3declare(strict_types=1);
4
5// TODO unit test
6
7use Psr\Http\Message\ResponseInterface;
8use Slim\Exception\HttpForbiddenException;
9use Slim\Exception\HttpNotFoundException;
10use Slim\Http\ServerRequest as Request;
11use Psr\Http\Server\RequestHandlerInterface as RequestHandler;
12use Slim\Routing\RouteContext;
13
14class 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}