i know i can through
throw new \ZfcRbac\Exception\UnauthorizedException('Not authorized!');
but i need
if user not logged in to be redirected to login page
if logged in with no permission isGranted('permission') then he get the Not authorized message
like this
if (!$this->isGranted('foo')) {
//handle redirect strategy
}
i know this can be made manually but i need to reuse the exist redirect strategy
if this possibly can be done
if (!$this->isGranted('foo')) { $app = $this->getServiceLocator()->get('Application'); $em = $app->getEventManager(); $mvcEvent = $app->getMvcEvent(); $mvcEvent->setError(Rbac::ERROR_CONTROLLER_UNAUTHORIZED) ->setParam('identity', $this->identity()); $em->trigger('dispatch.error', $mvcEvent); $response = $mvcEvent->getResult(); return $response; }
i know i can through throw new \ZfcRbac\Exception\UnauthorizedException('Not authorized!'); but i need if user not logged in to be redirected to login page if logged in with no permission isGranted('permission') then he get the Not authorized message like this
if (!$this->isGranted('foo')) { //handle redirect strategy
}
i know this can be made manually but i need to reuse the exist redirect strategy if this possibly can be done
related https://github.com/ZF-Commons/zfc-rbac/issues/230 https://github.com/ZF-Commons/zfc-rbac/issues/70