Permalink
Browse files

Renamed to AG_Auth

  • Loading branch information...
1 parent d930566 commit a1637f8f0be214a4c8e82f2fe3ebcfe74bb53e89 @adamgriffiths committed Aug 21, 2011
Showing with 441 additions and 12 deletions.
  1. +66 −0 config/ag_auth.php
  2. +12 −12 core/MY_Controller.php
  3. +23 −0 language/english/ag_auth_lang.php
  4. +272 −0 libraries/AG_Auth.php
  5. +68 −0 models/ag_auth_model.php
View
@@ -0,0 +1,66 @@
+<?php
+/**
+* Authentication Library
+*
+* @package Authentication
+* @category Libraries
+* @author Adam Griffiths
+* @link http://adamgriffiths.co.uk
+* @version 1.0.6
+* @copyright Adam Griffiths 2009
+*
+* Auth provides a powerful, lightweight and simple interface for user authentication
+*/
+
+
+/**
+* The array which holds your user groups and their ID.
+* If you have a database table for groups, these ID's must be the same as in the database.
+*/
+$config['auth_groups'] = array(
+ 'admin' => '1',
+ 'editor' => '2',
+ 'user' => '100'
+ );
+
+/**
+* The default URI string to redirect to after a successful login.
+*/
+$config['auth_login'] = 'admin/dashboard';
+
+/**
+* The default URI string to redirect to after a successful logout.
+*/
+$config['auth_logout'] = 'login';
+
+/**
+* The URI string to redirect to when a user entered incorrect login details or is not authenticated
+*/
+$config['auth_incorrect_login'] = 'login';
+
+
+/**
+* bool TRUE / FALSE
+* Determines whether or not users will be remembered by the auth library
+*/
+$config['auth_remember'] = TRUE;
+
+/**
+* The following options provide the ability to easily rename the directories
+* for your auth views, models, and controllers.
+*
+* Remember to also update your routes file if you change the controller directory
+* MUST HAVE A TRAILING SLASH!
+*/
+$config['auth_controllers_root'] = 'admin/';
+$config['auth_models_root'] = '';
+$config['auth_views_root'] = 'auth/';
+
+/**
+* Set the names for your user tables below (sans prefix, which will be automatically added)
+* ex.: your table is named `ci_users` with 'ci_' defined as your dbprefix in config/database.php, so set it to 'users' below
+*/
+$config['auth_user_table'] = 'users';
+$config['auth_group_table'] = 'groups';
+
+?>
View
@@ -56,24 +56,24 @@ function register()
if($this->form_validation->run() == FALSE)
{
- $this->auth->view('register');
+ $this->ag_auth->view('register');
}
else
{
$username = set_value('username');
- $password = $this->auth->salt(set_value('password'));
+ $password = $this->ag_auth->salt(set_value('password'));
$email = set_value('email');
- if($this->auth->register($username, $password, $email) === TRUE)
+ if($this->ag_auth->register($username, $password, $email) === TRUE)
{
$data['message'] = "The user account has now been created.";
- $this->auth->view('message', $data);
+ $this->ag_auth->view('message', $data);
- } // if($this->auth->register($username, $password, $email) === TRUE)
+ } // if($this->ag_auth->register($username, $password, $email) === TRUE)
else
{
$data['message'] = "The user account has not been created.";
- $this->auth->view('message', $data);
+ $this->ag_auth->view('message', $data);
}
echo('7');
@@ -87,23 +87,23 @@ function login($redirect = NULL)
if($redirect === NULL)
{
- $redirect = $this->auth->config['auth_login'];
+ $redirect = $this->ag_auth->config['auth_login'];
}
$this->form_validation->set_rules('username', 'Username', 'required|min_length[6]');
$this->form_validation->set_rules('password', 'Password', 'required|min_length[6]');
if($this->form_validation->run() == FALSE)
{
- $this->auth->view('login');
+ $this->ag_auth->view('login');
}
else
{
$username = set_value('username');
- $password = $this->auth->salt(set_value('password'));
+ $password = $this->ag_auth->salt(set_value('password'));
$field_type = (valid_email($username) ? 'email' : 'username');
- $user_data = $this->auth->get_user($username, $field_type);
+ $user_data = $this->ag_auth->get_user($username, $field_type);
if($user_data['password'] === $password)
@@ -112,7 +112,7 @@ function login($redirect = NULL)
unset($user_data['password']);
unset($user_data['id']);
- $this->auth->login_user($user_data);
+ $this->ag_auth->login_user($user_data);
redirect($redirect);
@@ -121,7 +121,7 @@ function login($redirect = NULL)
else
{
$data['message'] = "The username and password did not match.";
- $this->auth->view('message', $data);
+ $this->ag_auth->view('message', $data);
}
} // if($this->form_validation->run() == FALSE)
@@ -0,0 +1,23 @@
+<?php
+/**
+* Authentication Library
+*
+* @package Authentication
+* @category Libraries
+* @author Adam Griffiths
+* @link http://programmersvoice.com
+* @version 1.0.4
+* @copyright Adam Griffiths 2009
+*
+* Auth provides a powerful, lightweight and simple interface for user authentication
+*/
+
+$lang['insufficient_privs'] = "You do not have sufficient privileges to access this page.";
+$lang['username_callback_error'] = "The username was not found in our database.";
+$lang['reg_username_callback_error'] = "The username is in use, please select another username.";
+$lang['reg_email_callback_error'] = "The email is in use, please select another email.";
+$lang['login_details_error'] = "The username and password did not match our records, please try again.";
+$lang['max_login_attempts_error'] = "You have exceeded your maximum number of attempted logins, if you have forgotten your password, please consult the lost password form. You will be able to login again in 15 minutes.";
+$lang['logout_perms_error'] = "You have been logged out due to a permission error, please login again.";
+
+?>
Oops, something went wrong.

0 comments on commit a1637f8

Please sign in to comment.