We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Grant access all controller to guest but private?

I'm have crated an app base on Invo but it has a problem in security plugin. If you enter any string after baseurl it will return this "You don't have access to this page". It happen because ditpatcher in security plugin will take care all route as valid url. So using route->notFound didn't work.

does anyone have a idea?



135
Accepted
answer
edited May '14

It's very simple. Instead of using beforeDispatch use beforeExecuteRoute:

public function beforeExecuteRoute(Event $event, Dispatcher $dispatcher)
{
    $auth = $this->session->get('auth');
    ...