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

This seems like a 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 turn on / player / login, it redirects me to the "Missing Controller" page and changes the links 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 the $ components array helped, I think: D

+2
source share
3 answers

, , . , , , ( , ​​ Form, Basic, Digest, ecc..).

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

( $components)

+4

public $components=array(
    'Session',
    'Auth'=>array(
        'authenticate'=>array(
            'Form'=>array(
                'userModel'=>'Player',
             )
        ),
        'loginAction'=>array('controller'=>'Players', 'action'=>'login'),
0

Use this code in the controller:

public $components = array(
    'Auth' => array(
    'loginRedirect' => array(
        'controller' => 'applications',
        'action' => 'index'
    ),

    'logoutRedirect' => array(
        'controller' => 'applications',
        'action' => 'login'
    ),

    'authenticate' => array(
            'Form' => array(
                'passwordHasher' => 'Blowfish',
                'userModel' => 'Application'
            )
        ),      
    )
);

No need to add code for the beforeFilter () function. $ components load the Auth component.

Thanks Sujay

0
source

All Articles