-1

I am new to CakePHP, planning to develop a marketplace website using CakePHP. Four types of users will use this website. 1. Anonymous 2. Administrator 3. Service Provider 4. Service Seeker

Can i use ACL plugin to develop the website. OR should i store these users in different tables and use this technique? CakePHP 2.x Auth with Two Separate Logins

Kinldy guide me which technique to use with it's structure.

Community
  • 1
  • 1
Webgrity
  • 99
  • 1
  • 9

2 Answers2

0

Here, ACL will be the best solution. You don't have to manage anything manually. You only have to implement ACL successfully, that's it.

  • Should i create these tables ( acos, aros, aros_acos, users, groups )? Where users table will have user info. and groups will have four records. (1. Anonymous 2. Administrator 3. Service Provider 4. Service Seeker) Please note all the different type of users will have different fields. Kindly elaborate your answer. – Webgrity Oct 08 '14 at 09:20
  • Follow this tutorial : http://book.cakephp.org/2.0/en/tutorials-and-examples/simple-acl-controlled-application/simple-acl-controlled-application.html, spend some time with it, then come back, I'll try to clear your confusions. Only what I'll tell you now, you can definitely have these 4 kinds of users, these are groups actually. Then you just have to keep these group_ids in your User table. And, I think you should use just 1 table(User) for all users' login credentials. That way you can keep your project-structure simple.@Basant – Musabbir Ahmed Oct 08 '14 at 09:49
  • Thank you for your reply. I have one problem, please let me know how to redirect a particular group of users to his/her dashboard. For example admin group of users should redirect to admin dashboard after login and service providers should redirect to service provider dashborad after login. – Webgrity Oct 09 '14 at 05:26
  • Use loginRedirect(), in either your AppController or the specific controller for that user(Administrator, Service Provider, etc.). Configure this function in that controller. – Musabbir Ahmed Oct 09 '14 at 09:44
0

Having separate logins is against KISS and doesn't make much sense in any case. The only difference for example between a frontend and backend login is usually the view. Nothing else. If you have different user types they will still have a single login. Even if their data differs this should be abstracted by having one table that deals with the accounts (users) and another that is associated and contains the data (User hasOne FooProfile, User hasOne BarProfile). The association to the data or profile type table can be done on the fly after login depending on the user type.

ACL is relativly complicated and can become slow. Depending on the requirements I would evaluate role based access as well. I've written an easy to use RBAC adapter for CakePHP. See the test case to get an idea how it works. Basically you just have to define a map for the roles. By default the users table needs a field roleit can contain a single role or a comma separated list of roles. You can even have a table with roles but then need to generate that comma separated list, because thats what the adapter is expecting.

floriank
  • 25,546
  • 9
  • 42
  • 66