• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Ion Auth - Lightweight Auth System based on Redux Auth 2

#1
[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:
http://github.com/benedmunds/CodeIgniter-Ion-Auth


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.

INSTALLATION:
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
system/application/config/ion_auth.php.

USING THE LIBRARY:
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.


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



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


Thanks,

#2
[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.

Cheers,

Julien

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

You can use ->is_group('moderator')


Enjoy,

#4
[eluser]betabeta[/eluser]
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>
to
<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:
$this->ci->session->unset_userdata('identity');

(Or maybe do the unsetting in the model)



Thanks once more.

#5
[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

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

will this do what you need?



Thanks!

#6
[eluser]betabeta[/eluser]
Thanks! That's a much better way to do it.

#7
[eluser]betabeta[/eluser]
Hi Ben,

A couple more for you to fix activation emails:

controller/auth.php

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


libraries/Ion_auth.php

Line 203:
// deactivate takes $id instead of $username
Code:
$deactivate = $this->ci->ion_auth_model->deactivate($register);
Line 212:
// need to add ->row() or else can't get properties for email
Code:
$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.

#8
[eluser]Markko[/eluser]
Hey!

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

#9
[eluser]Ben Edmunds[/eluser]
Markko,

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

#10
[eluser]Markko[/eluser]
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


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2017 MyBB Group.