views:

18

answers:

1

I would like to know how to make a login in CakePhp when my data comes from 2 tables. Due to the specifications in the application the data in the table is divided like this: users: details: id id idDetail username group_id password

While doing the login from the users_controller, I would like to make the Auth component to check the username and password from the view against the details table. Is there such a way to do this login mechanism without doing it from the details_controller? or a way to login from details_controller and making the ACL to check the users table to grant access?

Thanks.

A: 

It's very easy. Create a model which is linked to the DB view. Basically it will be an empty model like:

class UserView extends AppModel {
    var $name = 'UserView';
}

now in your AppController's beforeFilter action use

$this->Auth->userModel = 'UserView';

And this should do the job. Take a look on this article in the cookbook

Nik
I'm just wondering whether you still use the UsersController and if so do you need to loadModel the User model?
Leo
@firith: are the two tables related?
Leo
Yes, they were related. I had to override the Auth::identify component to get this working, thanks a lot :)