CakePHP - Two types of users to authenticate
I would like 开发者_StackOverflowto have two different registrations/logins in the same application. One for companies and one for employees because registering a company requires different information than registering an employee.
Is it possible to use the auth component to achieve two different registrations/logins?
You can dynamically change the AuthComponent's configuration in a beforeFilter()
. For example:
function beforeFilter() {
if (/* company login required */) {
$this->Auth->userModel = 'Company';
// or:
$this->Auth->userScope = array('User.type' => 'company');
}
}
精彩评论