I am developing an authentication system in CakePHP. I have two kind of users; Applicant and Employer. I have a User table and controllers, models and views for each of them:
controllers:
users_controller.php
applicants_controller.php
employers_controller.php
models:
user.php
applicant.php
employer.php
views:
开发者_如何学编程 applicants:
register.ctp
employers:
register.ctp
In this way, when I want to register an Applicant I use the Applicant controller, model and register view. The same for the Employer. But I am repeating myself. What is the best way to implement this? Should I use ACL?
Thanks
If these are your only differences I would go with just one User-table and only set flags accordingly.
For this you would need 2 more table-fields called applicant
and employee
. Just use tinyint(1)
so Cake can use it as boolean value.
In your AppController you then can check (after authing with the AuthComponent) for these two values and allow or deny actions.
精彩评论