I’m using Tank Auth and my project will support two access type: “normal user” and “admin”. I looked at the tank auth database and there is a “isadmin” field, so I believe that it’s possible redirect to /admin or /user when I log in to my system.
How can I do this? I only see is_logged_in().
I already saw this: http://codeigniter.com/forums/viewthread/207245/ but I want only a redirect to /user or /admin URL depending if admin or not.
Unfortunately, Tank_Auth doesn’t come with any kind of user group or permission features built in. I’m not sure where you saw a field called
isadminbecause it doesn’t seem to be part of the current default setup and I couldn’t even find the word “admin” in the package files.This is the easiest solution I can think of:
Add the
is_adminfield you mentioned to the users table and manage it manually.Working with the way Tank_Auth currently does, you’ll be reading the user data from the session, so you’ll have to add it to the session on login.
Then add your own function to the library:
Then you’ll have to add this to the login controller for the redirect upon login:
Then have your admin controller always check for
$this->tank_auth->is_admin().This is the shortest route I can offer to achieve your goals – probably not the best, but you might be interested in Ion_Auth which does handle user groups by default.