<commit_before># Codeigniter User Library V. 0.8
This library is a **very simple** user auth library for Codeigniter. If you're looking into more complex and secure, this is not for you.
The library works by simple passwords md5 hashing with some functions that can help you out.
I'll adding things to it as I need em. Fell free to request a pull.

## Quick Start
* Import the _userschema.sql_ to your database.
* Merge the content of the folders with you Codeigniter root.
* You may need to set your secret session key on your config file and also set up your database config properly if you haven't yet.
* Head to /index.php/login/ and try your new auth system.

## Usage
Here is listed some of the most common actions when managin the user auth flow on your site. Examples of:
### Logging a user in
	if($this->user->login($login, $password)){
		echo "Logged in!";
	} else {
		echo "Wrong credentials!";
	}

### Validating a session
	if($this->user->validate_session()) {
		echo "Session is still valid.";
	}

### Redirect user based on valid session
	$this->user->on_invalid_session('home/login');

### Get the current logged in user id
	echo $this->user->get_id();

### Get current user name
	Welcome <?php echo $this->user->get_name();?>!

### Check permission
	if($this->user->has_permission('editor')){
		$this->load->view('editor_menu');
	}

### Logout user
	$this->user->destroy_user();


## Managing users
There is a separated library for user managing. After setting up the database config, load up the user_manager library. Some examples of
### Creating a permission
	$permission_id = $this->user_manager->save_permission('editor', 'The editors of my website.');

### Adding a new user
	$fullname = "<NAME>";
	$login = "MJ"
	$password = "<PASSWORD>";
	$active = true;
	$permissions = array(1, 3, 6);
	$this->user_manager->save_user($fullname, $login, $password, $active, $permissions);


### Deleting a user
	$this->user_manager->delete_user($user_id);

## Documentation
I still working on a good, standalone documentation for the project, it will be released soon. Thanks.

## Codeigniter Sparks
[Codeigniter Sparks](http://getsparks.org/) is an amazing project. It's something like a "package manager" for Codeigniter. Im on that, when I got some free time I'll read how can I put my package on Sparks.<commit_msg>Fixed the README file<commit_after># Codeigniter User Library V. 1.0
This library is a **very simple** user auth library for Codeigniter. The libraries uses sha1 hashing with salt.
I'll adding things to it as I need em. Fell free to request a pull.

## Quick Start
This is a quick guide to help you run your user system.
* Import the _database\_schema.sql_ to your database. There are 3 tables with users and permissions.
* Merge the content of the folders with you Codeigniter root.
* Change your encryption key on your application _config.php_ file and also set up your database config properly if you haven't yet.
* Load your database library automatically. This can be done on _autoload.php_, under _libraries_ session.
* Head to http://example.com/index.php/user and try your new auth system. There is a simple demonstration within this library.

## Usage
Here is listed some of the most common actions when managin the user auth flow on your site. Examples of:
### Logging a user in
	if($this->user->login($login, $password)){
		redirect('private_page');
	} else {
		echo "Wrong credentials!";
	}

### Validating a session
	if($this->user->validate_session()) {
		echo "This is secret.";
	}

### Auto redirect on invalid session
	$this->user->on_invalid_session('home/login');

### Auto redirect on valid session
	$this->user->on_valid_session('home/login');

### Get the current logged in name/id
	echo $this->user->get_name();
	echo Welcome, $this->user->get_id();

### Check permission
	if($this->user->has_permission('editor')){
		$this->load->view('editor_menu');
	}

### Logout user
	$this->user->destroy_user();


## Managing users
There is a separated library for user managing. After setting up the database config, load up the user_manager library. Some examples of

### Adding a new user
	$fullname = "<NAME>";
	$login = "john"
	$password = "<PASSWORD>";
	$active = true;
	$permissions = array(1, 3);
	$new_user_id = $this->user_manager->save_user($fullname, $login, $password, $active, $permissions);

### Creating a permission
	$permission_id = $this->user_manager->save_permission('editor', 'The editors of my website.');

### Deleting a user
	if( $this->user_manager->delete_user($user_id)){
		echo "User was deleted.";
	}

## Codeigniter Sparks
[Codeigniter Sparks](http://getsparks.org/) is an amazing project. It's something like a "package manager" for Codeigniter. Im on that, when I got some free time I'll read how can I put my package on Sparks.
{'fraction_non_alphanumeric': 0.11682632236568097, 'fraction_numerical': 0.0024989587671803417, 'mean_word_length': 4.533410138248848, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 54, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '275335', 'n_tokens_mistral': 1441, 'n_tokens_neox': 1397, 'n_words': 599}