Welcome Guest, Not a member yet? Register   Sign In
Myauth library - an easy to use authentication library!
#1

[eluser]koku[/eluser]
Hi all!

I started using CodeIgniter a couple of days ago for a project. I'm still looking into everything and I'm still learning the framework.

Like everyone else I needed authentication in the framework Smile I saw some nice libraries, but decided to write my own. I'm posting it here hoping to get some comments on it so I can improve it. Most certainly there are some parts that need improvement or maybe I did something stupid which could have been done easier. Just let me know!

If you like the library you may use it (of course Smile).

You can get it here

To use:
The ZIP includes a .sql file for MySQL. The users table is optional. The logins table is required. After getting the database part right, put the Myauth.php into the application/libraries dir and the config_myauth.php into the config dir.
In your autoload.php file add 'myauth' to the libraries to autoload. Also make sure that 'session' is autoloaded as well.
Now open config_myauth.php. This file contains all settings for the myauth library. Make sure you set the users table name and fieldnames correctly.

That's all. You can now create your controller that will log a user in. To log a user in, use the do_login() method. So fromout your controller:
$result = $this->myauth->do_login($_POST['username'], $_POST['password'], true/false);
The third parameter (boolean) can be used to set a cookie, so that the user is logged in automatically. When no parameter is given, no cookie will be created.

I hope this is clear, if not, let me know!

Thanks in advance for your thoughts!

KoKu
#2

[eluser]koku[/eluser]
Just a little kick, hoping someone can take a look at this library. I'm curious about your opinion...

Download here
#3

[eluser]bcorcoran[/eluser]
Trying this out now...

Would it be possible for you to write a brief tutorial on how you use the library yourself?

The thing that I find most confusing about all these Auth libraries is that they all use slightly different methods of authorizing the user... and in that regard it is confusing because I can't reliably figure out what I need to do to:

1) log someone in
2) verify if they are logged in on whatever pages i want to protect

I tried Erkana 1.0 and 2.0 and his example for logging in leaves out some key details that I can't seem to figure out on my own so it is pretty much useless to me.

I am not an expert at PHP, nor did I write any of these libraries so I can't given an opinion on any of them since I can't figure out how to get them to work!

Hopefully I can get yours to work...




Theme © iAndrew 2016 - Forum software by © MyBB