Separating admin login & member login in CakePHP ACL

203 views Asked by At

I am beginner to CakePHP Acl. I have successfully implemented the ACL component in my CakePHP project. I am facing two major problem with ACL. First of all this is my table structure.

groups
------
id
title
created
modified

users
-----
id
group_id
title
status (0 => inactive, 1 => active, 2 => suspended)
created
modified

My first problem is that i have two user groups "admin", "members". How can i restrict the members to login the admin panel. Since ACL using the "users" table for admin user and member user login.

The second problem is that how can i restrict the inactive and suspended user login with a customize error message like your account is suspended.

2

There are 2 answers

0
Tikaram Bhandari On BEST ANSWER

Admin routing can be used to separate members login. That can be done during the cake bake process. http://bakery.cakephp.org/articles/nate/2009/07/14/secrets-of-admin-routing

Use session flash message to show error message based on the condition from your controller. http://book.cakephp.org/2.0/en/core-libraries/components/sessions.html

0
Nizam On

Do follow the cookbook. In there, there are things mentioned on how to do your desired action.

http://book.cakephp.org/2.0/en/core-libraries/components/authentication.html

For problem no 1, I would suggest you can the user type and redirect them to specific page manually on successful login.

For problem 2. try to read the cookbook and look at something called 'scope' to specify what user can login and go thorugh other method also. That might be able to help you.