【发布时间】:2014-04-23 16:26:17
【问题描述】:
匿名用户正在访问以下需要经过身份验证的用户的 URL:/myprofile/settings。我希望能够中止 MVC 调度循环并将用户发送到登录位置。
代码:
$evt = $di->getShared('dispatcher')->getEventsManager();
$evt->attach('dispatch', new AccessControl\Security($di));
安全类:
/**
* This action is executed before execute any action in the application
*/
public function beforeDispatch(Event $event, Dispatcher $dispatcher)
{
// User is not authenticated, access should be denied.
$this->response->redirect('/signin');
}
问题。我如何告诉调度员跳过路由到myprofile Controller 和settings Action 而转储响应(将重定向到/signin)。
$event->stop() 不起作用。
谢谢!
【问题讨论】: