I am upgrading an app from CakePHP 1.3 to CakePHP 2.2.1 .
We are implementing ACL and in AppController I saw
if (isset($this->Auth)) {
if ($this->use_acl) {
$this->Auth->authorize = 'actions';
}
As a variable declaration I have already made changes to the following :
var $components = array(
'Auth' => array(
'authenticate' => array(
'Form' => array(
'fields' => array('username' => 'email', 'password' => 'password')
)
),
'loginAction' => array(
'admin' => false, 'prefix' => false, 'controller' => 'users',
'action' => 'login')
),
'Session', 'Facebook.Connect');
does it still require me to keep:
$this->Auth->loginAction = array('admin' => false, 'prefix' => false, 'controller' => 'users', 'action' => 'login');
The code work may sound ugly but, that is how upgrades are! 😉
Also, can I use the $this->Auth-> ‘auth properties’ in 2.2.1 as it was possible in 1.3 ?
As usual, the best place to get started with questions like this is the manual. Then, post the results of your tests rather than your code and a broad question.
That said, the first block of code you posted looks like a custom variable on your end
$this->use_acl. I’ve never seen that used in CakePHP, so there’s some flag your setting in your app to use ‘actions’.The second block of code looks pretty standard. It should work. Yes, you still need to specify a login action so that when a user tries to navigate to a page that is protected, then he/she will be redirected to the login. That said, there are differences in the login process as noted in the manual link above. You should take a look at the differences as to when a password is hashed and the login() function itself as they both have changed. The fact you are using ACL shouldn’t matter much as far as Authentication differences between the two version.
Your last question
Also, can I use the $this->Auth-> 'auth properties' in 2.2.1 as it was possible in 1.3 ?, the answer is yes. You should take a look at theAuthComponent.phpfile in the lib/Cake folder. It’s heavily commented about the information you are asking about here. There are even examples.