Dan C
Dan C

Reputation: 495

Codeigniter - How to achieve different member areas within a site? Tank_Auth

I have built an app using codeigniter which has 3 different member groups

Admininstrators - Who login to a dashboard and have CRUD facilities to Add/Edit/Delete Events, shows and artists

Clients - Who Login from the front end and see all the items that the admin have added via the back end.

Media Partners - Who Login from the front-end and see certain parts of what the client can see but not all things.

I have integrated the Tank_Auth Library for the Clients section which all works fine. What I would like to achieve though is for the administrator to be able to login to a seperate admin area and the media partners to be able to login to a seperate area too.

What is the best way to approach this?

Do I need to create sepearate dashboard controllers for each userbase and duplicate the Tank_Auth controller 3 times and tweak this?

Ideally The Admin users also need to be able to add news users and login to all 3 seperate areas?

Has anybody achieved such a solution before, If so how did you go about it? perhaps tank auth isn't the correct approach?

Any input would be appreciated.

Thanks Dan

Upvotes: 0

Views: 1286

Answers (3)

Amitabh
Amitabh

Reputation: 739

Absence of user group is a pain when using tank_auth if we have multiple user groups. I ran into this issue recently. Here is the solution posted in CI forms.

Using tank_auth for both front end user registration and login and back end admin login

Upvotes: 0

tplaner
tplaner

Reputation: 8461

I can't find the thread on the CI forums because I can't seem to login to their website right now, however do a search for 'zend_acl in codeigniter'. Alternatively there is this blog post about how to implement it, but it is slightly dated.

ACL stands for Access Control List, it will allow you to setup various permissions for different types of users. Zend has one of the best implementations of ACL in my opinion.

More information about ACL's can be found on zend's website.

Upvotes: 1

Tornike
Tornike

Reputation: 1254

I am using CI, but haven't used Tank_Auth, I have my auth class and in every function I have the following method called: $this->auth->accessMap(get_class($this),__FUNCTION__);

In auth class: public function accessMap($controller_name,$function_name) { if ($this->perms_array[$controller_name][$function_name]) return true; else $this->redir(); }

I have permissions array in config:

$config['user_perms']['className']['method1'] = array($config['user_types']['admin']);
$config['user_perms']['className']['method2'] = array($config['user_types']['admin'],$config['user_types']['user']);

Like this you can specify for each method which user has permission to use it.

I hope this will help.

Upvotes: 1

Related Questions