Ejemplo n.º 1
0
 public function testHasRole()
 {
     $annotation = new Annotation();
     $annotation->setObject($this->controller);
     $annotation->setMethod('indexAction');
     $roles = $annotation->getRoles();
     $this->assertSame('guest', $roles[0]->getName());
 }
Ejemplo n.º 2
0
 /**
  * @param \Zend\Mvc\MvcEvent $e
  */
 public function onDispach(MvcEvent $e)
 {
     $this->setEvent($e);
     $annotation = new Annotation();
     $annotation->setObject($this->getController());
     $annotation->setMethod($this->getMethodName());
     $roles = $annotation->getRoles();
     $auth = new AuthorizedInvokable($e->getApplication()->getServiceManager()->get('AuthService')->getStorage()->read(), $roles);
     try {
         $auth();
     } catch (\Exception $ex) {
         $this->setUnauthorized($ex);
     }
 }