I've tried adding joins in my User model beforeFind():

        public function beforeFind(array $query) {
                $query['joins'] = array(
                        array(
                                'table' => 'roles_users',
                                'alias' => 'RolesUser',
                                'type' => 'INNER',
                                'conditions' =>
array('Milli.id=RolesUser.user_id')),
                        array(
                                'table' => 'roles',
                                'alias' => 'Role',
                                'type' => 'INNER',
                                'conditions' =>
array('RolesUser.role_id=Role.id')));

                return $query;
        }

Now Model::find() correctly does receives the join info:
/lib/Cake/Model/Model.php (line 2676)

array(
        'conditions' => array(
                'Milli.username' => 'rihad',
                'Milli.password' => '17bce4ac9c39019189b7bba280af55de9fe1d9a7'
        ),
        'fields' => null,
        'joins' => array(
                (int) 0 => array(
                        'table' => 'roles_users',
                        'alias' => 'RolesUser',
                        'type' => 'INNER',
                        'conditions' => array(
                                (int) 0 => 'Milli.id=RolesUser.user_id'
                        )
                ),
                (int) 1 => array(
                        'table' => 'roles',
                        'alias' => 'Role',
                        'type' => 'INNER',
                        'conditions' => array(
                                (int) 0 => 'RolesUser.role_id=Role.id'
                        )
                )
        ),
        'limit' => (int) 1,
        'offset' => null,
        'order' => array(
                (int) 0 => null
        ),
        'page' => (int) 1,
        'group' => null,
        'callbacks' => true,
        'recursive' => (int) 2

But the User is still fetched with Role side by side, so
BaseAuthenticate ignores Role.

array(
        (int) 0 => array(
                'Milli' => array(
                        'password' => '*****',
                        'id' => (int) 6,
                        'username' => 'rihad',
                        'password_expiration' => null,
                        'created' => '2012-05-15 16:30:10',
                        'modified' => '2012-05-18 10:14:07',
                        'last_accessed' => null
                ),
                'Role' => array(
                        (int) 0 => array(
                                'id' => (int) 1,
                                'alias' => 'operations',
                                'RolesUser' => array(
                                        'id' => (int) 6,
                                        'role_id' => (int) 1,
                                        'user_id' => (int) 6
                                )
                        )
                )
        )
)


I'm expecting Role to be nested inside Milli, or something like that.

Please help, it's a SNAFU, I've invested too much of my limited time
to get the job done, it's too late to go looking for a working
framework :( I admit that it's probably a misconfiguration from my
part. But I can't fix it.

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to