Welcome Guest, Not a member yet? Register   Sign In
Ion Auth - Lightweight Auth System based on Redux Auth 2

[eluser]Ben Edmunds[/eluser]
Hey everybody,

Just wanted to "officially" announce the release of Ion_Auth. It's based on Redux Auth 2 but with a whole lot more awesomeness added in.

You can get it here:

Redux Auth 2 had a lot of potential. It's lightweight, simple, and clean,
but had a ton of bugs and was missing some key features.

So I've refactored the code and added new methods and functions with the much
appreciated help of Phil Sturgeon.

Just copy the files from this package to the corresponding folder in your
application folder. For example, copy Ion_auth/config/ion_auth.php to

In the package you will find example usage code in the controllers and views
folders. The example code isn't the most beautiful code you'll ever see but
it'll show you how to use the library and it's nice and generic so it doesn't
require a MY_controller or anything but it will be easy to add render() methods
if needed since there is only one load->view() per controller method.

It is highly recommended that you use encrypted database sessions for security!

Feel free to send me an email if you have any problems.


[eluser]Julien Dreux[/eluser]
Hi Ben,

I was just looking for a nice authentication library. I really like redux but it seems to be dead now, unfortunately. So I like what you're doing.

I saw in your sample controller that you called functions like $this->ion_auth->logged_in() or $this->ion_auth->is_admin(). Is it possible with Ion Auth to define custom roles like for example $this->ion_auth->is_moderator() without having to modify the library?

I just released a new version of TagMVC that could use a feature like that.



[eluser]Ben Edmunds[/eluser]
Thanks Julien,

You can use ->is_group('moderator')


Hi Ben,

Giving your library a shot. Perfect timing for my project. Thanks for sharing!

I'm still learning codeigniter but I found a couple little bugs and also have a suggestion to pass by you. I can keep posting to this thread if this is helpful.

Thanks again.

auth.php, line 167, remove line:
echo $reset; //debug

auth/index.php, line 21, change line:
<td>&lt;?php echo $user['group_description'];?&gt;</td>
<td>&lt;?php echo $user['group'];?&gt;</td>

Also would you ever consider adding a session variable 'identity', so the code maps more cleanly to which identity you choose in config?

ion_auth_model, line 537:
$this->session->set_userdata('identity', $result->{$this->identity_column});

And delete in logout
Ion_auth.php, line 255:

(Or maybe do the unsetting in the model)

Thanks once more.

[eluser]Ben Edmunds[/eluser]
Hey betabeta,

Thanks for the feedback!

The first two errors are fixed now and for the question about identity you can use

$identity = $this->session->userdata($this->config->item('identity'));

will this do what you need?


Thanks! That's a much better way to do it.

Hi Ben,

A couple more for you to fix activation emails:


Line 211 to 213:
// delete lines because new users are the ones that need to create accounts
if (!$this->ion_auth->logged_in() || !$this->ion_auth->is_admin()) {
    redirect('auth', 'refresh');


Line 203:
// deactivate takes $id instead of $username
$deactivate = $this->ci->ion_auth_model->deactivate($register);
Line 212:
// need to add ->row() or else can't get properties for email
$user            = $this->ci->ion_auth_model->get_user($register)->row();

Also it's weird to me that session vars are set in the model but deleted in the library.

I hope this is helpful.

EDIT: The activation email bugs mention here were resolved in the source as of 2010 Feb 13. Thanks.


How do I fetch eg. user id (or any data) from database who's currently logged in?

[eluser]Ben Edmunds[/eluser]

$user = $this->ion_auth->get_user();

Okey thanks Ben!

// Edit
Are you planning to make some documentation for your awesome Auth? I know this should be simple but what can I do when i'm still CI noob!? Wink

Theme © iAndrew 2016 - Forum software by © MyBB