EasyAuth

Code Igniter Library

Simple Database User Authentication Library

About / License

EasyAuth is a very simple authentication library for Code Igniter. EasyAuth is designed to work with new or existing apps, while using simple database authentication.

Feel free to modify / distribute / use this library however you wish. Please keep copyright intact. Thanks!


Download

Download EasyAuth Here EasyAuth.zip


Install

Download the zip file above, and unzip the file. Next copy Easyauth.php to your application's libraries folder. Besure to configure your autoloader (/system/application/config/autoload.php) to include 'easyauth'. It will look something like this.

$autoload['libraries'] = array('easyauth','someotherlib');


Configure

You can use the supplied users.sql file to create a very simple users table in MySQL. EasyAuth library is configured to use the users table. If you are adapting this library to a different table, then you can configure to the query to authenticate accordingly.


Implement

A simple implementation would be to check for the connected variable stored in the class. Connected ($connected) should either be true or false. If the user has a valid login then we should expect the $connected variable to be true.

<?php
class Blog extends Controller {
function index(){
if($this->easyauth->connected == true):
$this->load->view('dashboard');
else:
$this->load->view('login');
endif;
}
}
?>