Hatsuney Hatsuney - 1 month ago 21
PHP Question

How can I use different model for Auth component in CakePHP 2.0.4?

It looks like trivial thing, but I really can't find where I can change it.
I want to use my "Player" model instead of User, but every time I go on /players/login it redirects me to "Missing Controller" page and link changes to /users/login.

I tried:

public $components = array(
'Session',
'Auth' => array(
'authenticate' => array('all' => array('userModel' => 'Player'))
)
);


and

function beforeFilter() {
$this->Auth->authenticate = array('all' => array('userModel' => 'Player'));
}


EDIT: SOLVED

'loginAction' => array('controller' => 'players', 'action' => 'login')


in $components array helped, I think :D

Answer

I guess the problem is that you aren't providing an authenticating system. You're providing some settings to be used in all the authenticating system that will be chosen, but you haven't chosen one yet (you have to provide at least one like Form, Basic, Digest, ecc..).

$this->Auth->authenticate = array(
    'all' => array('userModel' => 'Member'),
    'Form',
    'Basic'
);

(or the same in the $components array)