Auth, Acl, and beforeFilter() Problem


#1

I currently have the AuthComponent configured in my AppController and beforeFilter call backs in many of my other controllers which looks something like this:

public function beforeFilter() {
	parent::beforeFilter();
	
	if ($this->request->params['action'] === 'index' || $this->request->params['action'] === 'view') {
		$this->checkPublicAccess('acoNode');
	}
}

The checkPublicAccess method is basically checking the Acl for permissions. All of that works fine. The problem I’m having is when the user isn’t authenticated and one of these pages are accessed, I get Acl errors.

2017-02-15 17:15:55 Error: [CakeException] AclNode::node() - Couldn't find Aro node identified by "Array
(
    [Aro0.model] => User
    [Aro0.foreign_key] => 
)

I figured out that beforeFilter() callback is actually getting executed before the AuthComponent does it’s thing. This is a problem for me. I need Auth to do it’s thing before Acl stuff is done. Would using ControllerAuthorize solve this problem? Is isAuthorized() simply a callback that happens after authentication, allowing me to then execute my Acl checks?