forked from bcit-ci/CodeIgniter
-
Notifications
You must be signed in to change notification settings - Fork 0
RA Auth
World Wide Web Server edited this page Jul 4, 2012
·
9 revisions
An authenication library from systemsos (Version 1.0) working.
Originally introduced here: [url]http://codeigniter.com/forums/viewthread/71537/[/url]
[code] <?php if (!defined('BASEPATH')) exit('No direct script access allowed'); /**
- CodeIgniter
- @package Rapidauth
- @author Darren Nolan - Rapid Hosting - Based on Erkana: CodeIgniter Authorization Library
- @copyright Copyright (c) 2008, Rapid Hosting
- @link http://www.rapidhosting.com.au
- @since Version 1.0
- @filesource */
class RA_Auth { var $CI;
function RA_Auth()
{
$this->CI =& get_instance();
log_message('debug', 'RapidAuth class loaded');
$this->CI->load->database();
}
function check_login ($condition = array(), $table = 'users', $select = 'id')
{
$this->CI->db->select($select);
$query = $this->CI->db->getwhere($table, $condition, 1, 0);
if ($query->num_rows != 1) {
return FALSE;
} else {
$row = $query->row();
$this->CI->ra_session->set_userdata(array('user_id' => $row->$select, 'authenticated' => 'TRUE'));
return TRUE;
}
}
function check_session ()
{
if ($this->CI->ra_session->userdata('user_id') AND $this->CI->ra_session->userdata('authenticated')=='TRUE') {
return TRUE;
} else {
return FALSE;
}
}
function logout ()
{
$this->CI->ra_session->unset_userdata('user_id');
$this->CI->ra_session->unset_userdata('authenticated');
$this->CI->ra_session->sess_destroy();
}
} ?> [/code]