Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
34 lines (28 sloc) 864 Bytes
<?php
/**
* @license http://opensource.org/licenses/BSD-3-Clause BSD-3-Clause
* @copyright Copyright (c) 2013 Zend Technologies USA Inc. (http://www.zend.com)
*/
namespace ZF\Apigility\MvcAuth;
use ZF\ApiProblem\ApiProblem;
use ZF\ApiProblem\ApiProblemResponse;
use ZF\MvcAuth\MvcAuthEvent;
class UnauthorizedListener
{
/**
* Determine if we have an authorization failure, and, if so, return a 403 response
*
* @param MvcAuthEvent $mvcAuthEvent
* @return null|ApiProblemResponse
*/
public function __invoke(MvcAuthEvent $mvcAuthEvent)
{
if ($mvcAuthEvent->isAuthorized()) {
return;
}
$response = new ApiProblemResponse(new ApiProblem(403, 'Forbidden'));
$mvcEvent = $mvcAuthEvent->getMvcEvent();
$mvcEvent->setResponse($response);
return $response;
}
}
You can’t perform that action at this time.