CodeIgniter Forums

Full Version: Help protecting controller with authentication
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum


I have a very basic application for learning purposes that basically views, adds, edits and deleted rows from a db.

Everything works fine but now I am trying to set it up so that when the user tries to edit or delete a record they are requested to authenticate (admin functions if you will).

I searched through authentication systems and unfortunately all I found had a lot more of what I needed. I tried using for the simple fact that it lets you protect specific functions in a controller by just adding
then it will do the work of checking if there is a session established, redirect to login page otherwise, etc.

The problem is that this library already has a "successful url" parameter and it redirects to this page once the session has been established but what I would like instead is to redirect to the page the user was requesting when they were asked to login.

I tried modifying this library to fit my needs but I am afraid I am no expert and I just couldn't get it done.

I thought it might be easier to just control my simple needs through my own model and controllers but I wanted to check if someone has run into a library or helper that does what I am trying to do without so many bows and whistles as a full authentication system.

Thanks very much in advance.

El Forum

In case somebody is in need of this I have finally accomplished it using Ion Auth:

Very simple to setup and very clean code.