phpcodeignitertankauth

Codeigniter admin user/customer auth separation


I'm currently using Tank Auth on my project.

I'd like to have separate logins for my admin area and main site. I'm using two different tables one for admin users and one for normal users.

At the moment if you login to either section and then go to the other section it still thinks you are logged in.

Is there anyway to do this using just Tank auth? (is this advisable) or should I be using two different auth methods?


Solution

  • Yes it is possible. You would not need to use two libraries, No. But you can look at the method login() already implemented and duplicate and make some small changes. However, instead of having two tables one for admin and one for users, I would have a column 'is_admin' or 'admin' which is a boolean. Now you can check If the user is an admin (boolean true) and If he is, you perform this "mega cool admin task" and if your not admin (boolean false) deny it.

    This way, you can store all users in one table - which would make it much easier for you.

    Have a look here http://johnwright.me/blog/tank-auth-groups-roles-admin/