In the past, I simply create a BaseController and check the session to control user to access for some pages
class BaseController extends Phalcon\Mvc\Controller
{
public function beforeExecuteRoute()
{
if(!$this->session->get("user"))
{
$this->dispatcher->forward(array(
'controller' => 'login',
'action' => 'index'
));
}
}
}
But now the system has many types of users
for example
if $this->session->get("user")->type=='admin'
Then this user can access AdminController
while $this->session->get("user")->type=='manager'
then this user can access ManagerController
I can create many BaseController for different user types, but I think this is not a good solution, can I solve it by using one base controller?