Created
November 4, 2012 14:07
-
-
Save eminetto/4012065 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Verifica se precisa fazer a autorização do acesso | |
* @param MvcEvent $event Evento | |
* @return boolean | |
*/ | |
public function mvcPreDispatch($event) | |
{ | |
$di = $event->getTarget()->getServiceLocator(); | |
$routeMatch = $event->getRouteMatch(); | |
$moduleName = $routeMatch->getParam('module'); | |
$controllerName = $routeMatch->getParam('controller'); | |
$actionName = $routeMatch->getParam('action'); | |
$authService = $di->get('Admin\Service\Auth'); | |
if (! $authService->authorize($moduleName, $controllerName, $actionName)) { | |
throw new \Exception('Você não tem permissão para acessar este recurso'); | |
} | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment