Skip to content

Commit

Permalink
Merge branch 'hotfix/1.1.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Funk committed Mar 3, 2012
2 parents 16133d5 + 66c7861 commit a711a9c
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 21 deletions.
12 changes: 2 additions & 10 deletions README.md
Expand Up @@ -10,7 +10,8 @@ Setup
1. Install sparks on [GetSparks.org](http://getsparks.org)
2. Edit **config/authentication.php** with the proper stuff like redirect urls, etc.
3. Import **setup.sql** in PHPMyAdmin or something
4. Load the spark: ```$this->load->spark('ci_authentication/1.1.0');```
4. Load the spark: ```$this->load->spark('ci_authentication/1.1.1');```
5. Load the library: ```$this->load->library('ci_authentication');```

*NOTE: If cloning this directly, be sure to also clone [CI Alerts](https://github.com/mikedfunk/CI-Alerts) version 1.1.0 as a spark and load it. CI Alerts are required for CI Authentication. The spark format requires this already as a dependency.*

Expand All @@ -19,7 +20,6 @@ Restrict

At the top of a CI controller method or in ```__construct()``` do this:

$this->load->spark('ci_authentication/1.1.0');
$this->ci_authentication->restrict_access();

It will redirect to the config_item for logged_out_url.
Expand All @@ -36,7 +36,6 @@ Do Login

When form validation passes, just do this:

$this->load->spark('ci_authentication/1.1.0');
$this->ci_authentication->do_login();

It will hash and salt the password, log in the user (add username, user id, and encrypted password to the session), and redirect to the configured home page in the roles table.
Expand All @@ -46,7 +45,6 @@ Remember Me

At the top of a CI controller method that does form validation insert this:

$this->load->spark('ci_authentication/1.1.0');
$this->ci_authentication->remember_me();

If the "remember me" checkbox is checked, it will save the username, password, and checked status of the remember me checkbox to cookies. You can use ```get_cookie('email_address')``` or whatever to load the form values into your login form by default.
Expand All @@ -56,7 +54,6 @@ Do Logout

For the logout controller method, do this:

$this->load->spark('ci_authentication/1.1.0');
$this->ci_authentication->do_logout();

It will destroy the session and redirect to the configured logged out url.
Expand All @@ -71,7 +68,6 @@ Do Register

When form validation passes for registration, do this:

$this->load->spark('ci_authentication/1.1.0');
$this->ci_authentication->do_register();

It will:
Expand All @@ -90,7 +86,6 @@ Do Confirm Register

You need to set a controller method for when a user clicks the confirmation link. In this method, just put this:

$this->load->spark('ci_authentication/1.1.0');
$this->ci_authentication->do_confirm_register();

It will check if a confirmation string exists for the passed string. If so, it will remove that string and redirect to the confirm_register_success_url. Otherwise it will redirect to the confirm_register_fail_url.
Expand All @@ -100,7 +95,6 @@ Do Resend Register

If you want to allow resending of the registration email, you need to add a controller method and link to it somewhere. That method needs to accept the confirm_string as a parameter or POST variable or something. In that method, just do this:

$this->load->spark('ci_authentication/1.1.0');
$this->ci_authentication->do_resend_register($confirm_string);

It will check if a confirmation string exists for the passed string. If so, it will resend the confirmation email and redirect to register_success_url.
Expand All @@ -115,7 +109,6 @@ Do Request Reset Password

You need to set a controller method for when a user requests to reset their password. In this method, just put this:

$this->load->spark('ci_authentication/1.1.0');
$this->ci_authentication->do_request_reset_password($email_address);

You will need to pass the ```$email_address``` variable. You could get this from a reset form or a link. This method will email a password link with an encrypted string based on the email address. The user must click this link to confirm they want to reset their password. This prevents passwords being reset without the user's consent. In case you need it the title for the alert page is set in flashdata based on the config value. Then the user is redirected to the request_reset_password_url.
Expand All @@ -125,7 +118,6 @@ Do Confirm Reset Password

You need to set a controller method for when a user clicks the reset password confirmation link. In this method, just put this:

$this->load->spark('ci_authentication/1.1.0');
$this->ci_authentication->do_request_reset_password();

This method will retrieve the username and encrypted string via $_GET variables. It will make sure the encrypted username matches the encrypted string, make sure a user exists with that username, set a new random password, email it to the user, update the user in the database with the new password (salted and encrypted), and redirect to the configured page.
2 changes: 1 addition & 1 deletion config/ci_authentication.php
Expand Up @@ -10,7 +10,7 @@
* @email mike@mikefunk.com
*
* @file ci_authentication.php
* @version 1.1.0
* @version 1.1.1
* @date 02/17/2012
*
* Copyright (c) 2012
Expand Down
2 changes: 1 addition & 1 deletion helpers/ci_authentication_helper.php
Expand Up @@ -10,7 +10,7 @@
* @email mike@mikefunk.com
*
* @file ci_authentication_helper.php
* @version 1.1.0
* @version 1.1.1
* @date 02/17/2012
*
* Copyright (c) 2012
Expand Down
16 changes: 8 additions & 8 deletions libraries/ci_authentication.php
Expand Up @@ -10,7 +10,7 @@
* @email mike@mikefunk.com
*
* @file ci_authentication.php
* @version 1.1.0
* @version 1.1.1
* @date 02/17/2012
*
* Copyright (c) 2012
Expand Down Expand Up @@ -68,8 +68,8 @@ public function restrict_access($condition = '')
{
// load resources
$this->_ci->load->model('ci_authentication_model', 'auth_model');
$this->_ci->load->library('session');
$this->_ci->load->spark('ci_alerts/1.1.0');
$this->_ci->load->library(array('session', 'ci_alerts'));
$this->_ci->load->helper('url');

// check for password match, else redirect
Expand Down Expand Up @@ -166,8 +166,8 @@ public function do_login()
{
$this->_ci->load->model('ci_authentication_model', 'auth_model');
$this->_ci->load->helper(array('encrypt_helper', 'string', 'url'));
$this->_ci->load->library('alerts');
$this->_ci->load->spark('ci_alerts/1.1.0');
$this->_ci->load->library('ci_alerts');

// unset temporary password and confirm password fields
unset($_POST['confirm_password']);
Expand Down Expand Up @@ -209,8 +209,8 @@ public function do_login()
*/
public function do_logout()
{
$this->_ci->load->library('alerts');
$this->_ci->load->spark('ci_alerts/1.1.0');
$this->_ci->load->library('ci_alerts');
$this->_ci->load->helper('url');

$this->_ci->session->sess_destroy();
Expand Down Expand Up @@ -293,8 +293,8 @@ public function resend_register_email($confirm_string)
private function _send_register_email($user_array)
{
$this->_ci->load->helper('url');
$this->_ci->load->library(array('email', 'session'));
$this->_ci->load->spark('ci_alerts/1.1.0');
$this->_ci->load->library(array('email', 'session', 'ci_alerts'));

// from, to, url, content
$this->_ci->email->from(config_item('register_email_from'), config_item('register_email_from_name'));
Expand Down Expand Up @@ -338,8 +338,8 @@ public function do_confirm_register($confirm_string)
// check for user with confirm_string
$this->_ci->load->model('ci_authentication_model', 'auth_model');
$this->_ci->load->helper('url');
$this->_ci->load->library('session');
$this->_ci->load->spark('ci_alerts/1.1.0');
$this->_ci->load->library(array('session', 'ci_alerts'));
$q = $this->_ci->auth_model->get_user_by_confirm_string($confirm_string);

// on match
Expand Down Expand Up @@ -381,8 +381,8 @@ public function do_request_reset_password($username)
{
// load resources
$this->_ci->load->helper(array('encrypt_helper', 'url'));
$this->_ci->load->library(array('email', 'session'));
$this->_ci->load->spark('ci_alerts/1.1.0');
$this->_ci->load->library(array('email', 'session', 'ci_alerts'));

// email reset password link

Expand Down Expand Up @@ -423,8 +423,8 @@ public function do_confirm_reset_password()
{
// load resources
$this->_ci->load->helper(array('encrypt_helper', 'string', 'url'));
$this->_ci->load->library(array('email', 'session'));
$this->_ci->load->spark('ci_alerts/1.1.0');
$this->_ci->load->library(array('email', 'session', 'ci_alerts'));
$this->_ci->load->model('ci_authentication_model', 'auth_model');

// get username and encrypted_username
Expand Down
2 changes: 1 addition & 1 deletion spark.info
Expand Up @@ -7,7 +7,7 @@ name: CI Authentication

# This is the current version of this spark. All sparks should be in
# x.x.x format. Validation will fail otherwise.
version: 1.1.0
version: 1.1.1

# This is the version of CodeIgniter this spark is compatible up to. It should
# be in x.x.x format
Expand Down

0 comments on commit a711a9c

Please sign in to comment.