Issue
I have three different types of users, all stored in different tables. I want to implement ACL to allow/deny certain access to them. The default behavior of cakephp acl plugin uses the "users" table & assigns them in "groups". Is there any way i can customize this to use multiple users table.
Thanks in advance.
Solution
disclaimer: I did not test what I'm going to write
I see that Acl have a userModel
parameter that you can config (see here).
So when loading the component you have to set it according to you actual user table
$this->loadComponent('Auth', [
'authorize' => [
'Acl.Actions' => [
'actionPath' => 'controllers',
'userModel' => 'Users' // <== you can change this
// i.e. to Guests, Admins...
],
],
of course you hve to set as requester every Table that can login
$this->addBehavior('Acl.Acl', ['type' => 'requester']);
The only problem I see here is that you don't know what kind of user you have until he is logged in. So you can set 'userModel' only after login. Maybe this can cause some issue at the login phase, I'm not sure.
Anyway I still believe that the simpler way is to use a single table and different roles.
Answered By - arilia
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.