Skip to content

Commit

Permalink
Updated documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
almasaeed2010 committed Oct 10, 2013
1 parent 2bc0d63 commit 7ca51f0
Show file tree
Hide file tree
Showing 3 changed files with 192 additions and 8 deletions.
148 changes: 148 additions & 0 deletions CI_AuthLTE_db.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
-- phpMyAdmin SQL Dump
-- version 3.2.5
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Oct 10, 2013 at 10:34 AM
-- Server version: 5.1.44
-- PHP Version: 5.3.2

SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;

--
-- Database: `hhp`
--

-- --------------------------------------------------------

--
-- Table structure for table `accounts`
--

CREATE TABLE `accounts` (
`user_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`email` varchar(120) NOT NULL,
`password` varchar(65) CHARACTER SET latin1 COLLATE latin1_general_cs NOT NULL,
`login_attempts` tinyint(4) NOT NULL DEFAULT '0',
`login_ban` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`last_login` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`reset_password_tk` varchar(65) CHARACTER SET latin1 COLLATE latin1_general_cs NOT NULL,
`reset_password_tk_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`email_verfication_tk` varchar(65) NOT NULL,
`email_verfication_date` datetime NOT NULL,
`date_added` datetime NOT NULL,
`group_id` int(11) NOT NULL DEFAULT '0',
`is_active` tinyint(1) NOT NULL DEFAULT '0' COMMENT '0 inactive 1 for active',
PRIMARY KEY (`user_id`),
KEY `group_id` (`group_id`),
KEY `email` (`email`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ;

-- --------------------------------------------------------

--
-- Table structure for table `account_privilege`
--

CREATE TABLE `account_privilege` (
`connection_id` int(11) NOT NULL,
`user_id` int(11) NOT NULL,
`privilege_id` int(11) NOT NULL,
PRIMARY KEY (`connection_id`),
KEY `user_id` (`user_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

-- --------------------------------------------------------

--
-- Table structure for table `ci_sessions`
--

CREATE TABLE `ci_sessions` (
`session_id` varchar(40) NOT NULL DEFAULT '0',
`ip_address` varchar(16) NOT NULL DEFAULT '0',
`user_agent` varchar(120) DEFAULT NULL,
`last_activity` int(10) unsigned NOT NULL DEFAULT '0',
`user_data` text NOT NULL,
PRIMARY KEY (`session_id`),
KEY `last_activity` (`last_activity`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- --------------------------------------------------------

--
-- Table structure for table `groups`
--

CREATE TABLE `groups` (
`group_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(40) NOT NULL,
`description` tinytext NOT NULL,
`is_admin` tinyint(4) NOT NULL COMMENT '1 for admin group or 0 otherwise',
PRIMARY KEY (`group_id`),
KEY `name` (`name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ;

-- --------------------------------------------------------

--
-- Table structure for table `group_privilege`
--

CREATE TABLE `group_privilege` (
`connection_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`group_id` int(11) NOT NULL,
`privilege_id` int(11) NOT NULL,
PRIMARY KEY (`connection_id`),
KEY `group_id` (`group_id`,`privilege_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=6 ;

-- --------------------------------------------------------

--
-- Table structure for table `ip_attempts`
--

CREATE TABLE `ip_attempts` (
`ip` varchar(15) NOT NULL DEFAULT '0.0.0.0',
`last_failed_attempt` datetime NOT NULL,
`number_of_attempts` int(11) NOT NULL,
PRIMARY KEY (`ip`),
KEY `last_failed_attempt` (`last_failed_attempt`),
KEY `number_of_attempts` (`number_of_attempts`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

-- --------------------------------------------------------

--
-- Table structure for table `privileges`
--

CREATE TABLE `privileges` (
`privilege_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(40) NOT NULL,
`description` tinytext NOT NULL,
PRIMARY KEY (`privilege_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=6 ;

-- --------------------------------------------------------

--
-- Table structure for table `remembered_users`
--

CREATE TABLE `remembered_users` (
`connection_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`user_id` int(11) NOT NULL,
`token` varchar(65) CHARACTER SET latin1 COLLATE latin1_general_cs NOT NULL,
`date` datetime NOT NULL,
PRIMARY KEY (`connection_id`),
UNIQUE KEY `token` (`token`),
KEY `user_id` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=32 ;
51 changes: 44 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,55 @@
AuthLTE
=======
This library is under construction! Projected release date 25 Oct 2015. Watch for updates!
CI_AuthLTE
==========
Beta version 0.1.0 has been released.

CI_AuthLTE is a light authentication library for codeigniter 2.x.

Light authentication library for codeigniter 2.x. It supports groups and privileges and is equipped with many powerful functions.

Dependencies
============
PHP 5.3 or higher

Codeigniter 2.x or higher

MySQL database

Main Features
=============
1- PHPass for password encryption
2- Limited login attempts
3- Secured "remember me" with limited time period
4- Forgetton password help
5- Optional activation email
6- Groups and priviledges control
7- Simple database structure

Documentation
=============
Installation:
Add the files to the corresponding directories. Then, dump the sql file to your database.
Open the auth_model.php file which is located in the Application/models directory. Make sure to edit the settings to match your desire.

Load the model using Codeigniter's load function:
```PHP
$this->load->model('auth_model');
```

Creating an account:
To create an account simply use the create_account() function. Example:
```PHP
$user_id = $this->auth_model->create_account($email, $password);
```
You can add customized data to the accounts table such as phone and name. Then you can use the 4th parameter of the create_account() function to add custom data to your table. Example:
```PHP
$custom_data = array(
"name" => "Foo Bar",
"phone" => "555-555-5555'
);
$user_id = $this->auth_model->create_account($email, $password, NULL, $custom_data);
```
If you want the account to be connected to a group, add the group id as a 3rd paramater.

Under construction
Logging In:
Log a user in using the login() function. Example:
```PHP
$this->auth_model->login($email, $password, $remember_me = FALSE);
```
The function will return (bool) TRUE on success. False otherwise.
1 change: 0 additions & 1 deletion application/.htaccess

This file was deleted.

0 comments on commit 7ca51f0

Please sign in to comment.