Conditions | 5 |
Paths | 3 |
Total Lines | 20 |
Lines | 0 |
Ratio | 0 % |
Tests | 11 |
CRAP Score | 5 |
Changes | 0 |
1 | <?php |
||
22 | 10 | public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface |
|
23 | { |
||
24 | 10 | $resource = $request->getAttribute(ResourceMiddlewareInterface::DATA_RESOURCE); |
|
25 | |||
26 | 10 | if ($resource && $resource instanceof ClaimedResourceInterface) { |
|
27 | 5 | $resourceOwner = $resource->getOwner(); |
|
28 | /** @var User|null $currentOwner */ |
||
29 | 5 | $currentOwner = $request->getAttribute(TokenMiddleware::USER_PARAM); |
|
30 | |||
31 | 5 | if (!$currentOwner || ($currentOwner->getId() !== $resourceOwner->getId())) { |
|
32 | 1 | return new JsonResponse([ |
|
33 | 1 | 'data' => [], |
|
34 | 1 | 'msg' => new DangerMessage('Access denied.'), |
|
35 | 'success' => false |
||
36 | 1 | ], 403); |
|
37 | } |
||
38 | } |
||
39 | |||
40 | 9 | return $handler->handle($request); |
|
41 | } |
||
42 | } |
||
43 |