Welcome Guest, Not a member yet? Register   Sign In
Redux Authentication 1.4a (24th July 2008)

[eluser]jonnyleeharris[/eluser]
[quote author="Popcorn" date="1213156506"]Can you paste me the echoed information?[/quote]

0e9f5727636ced0d20e92671997c7ee8452edbb9
9812e19a552444de33a730941dfa6296c4455808SUCCESS

Looks like the generated password and hash.

[eluser]Popcorn[/eluser]
Looks like some debug information I accidently left in somewhere, probably in the controller. Can you paste me your controller?

[eluser]jonnyleeharris[/eluser]
[quote author="Popcorn" date="1213157187"]Looks like some debug information I accidently left in somewhere, probably in the controller. Can you paste me your controller?[/quote]

Code:
$rules['username']     = 'trim|required|callback_check_username';
        $rules['email']     = 'trim|required|callback_check_email';
        $rules['password']     = 'trim|required|matches[confirm_password]';
        $rules['confirm_password'] = 'trim|required';
        $rules['question']     = 'trim';
        $rules['answer']     = 'trim';
            
        $this->validation->set_rules($rules);
        $this->validation->set_error_delimiters('<p class="error">', '</p>');
            
        if($this->validation->run())
        {
            $register = $this->redux_auth->register
            (
                $this->input->post('username'),
                $this->input->post('password'),
                $this->input->post('email'),
                $this->input->post('question'),
                $this->input->post('answer')
            );
            
            switch($register)
            {
                case 'REGISTRATION_SUCCESS':
                    echo "SUCCESS";
                    $contentData['content'] = $this->load->view('registerSuccess','', true);
                    $this->load->view('page', $contentData);
                    break;
                    
                case 'REGISTRATION_SUCCESS_EMAIL':
                    //redirect('');
                    echo "SUCCESS EMAIL";
                    break;
                default: // Failed
                    //redirect('');
                    break;
            }
        }
        else
        {
            $contentData['content'] = $this->load->view('registerForm','', true);
            $this->load->view('page', $contentData);
        }

[eluser]Popcorn[/eluser]
Ah yes, a mistake. Thank You.

Remove
Code:
echo "SUCCESS";
from the first case statement.

and please remove this from line 174 in your libraries/redux_auth.php file

Code:
echo $password .'<br>'. $result->password;

Sorry about that. I will update the website

[eluser]jonnyleeharris[/eluser]
Thanks a lot for your help!

[eluser]Pascal Kriete[/eluser]
There's a small bug in your sql dump. In the countries, 52 is just " Democratic Republic" and right before that you have 2 congos....you can probably see what went wrong Smile .

Also a small performance thing:
Code:
// Old
$message = preg_replace('/({key})/', $key, $this->forgotten_password_message);

// New
$message = str_replace('{key}', $key, $this->forgotten_password_message);

Ditto for the new password email.

[eluser]Popcorn[/eluser]
Thank you inparo. Will include this into the next update.

I'm always willing to hear advice, improvements, patches, etc ... I would love to hear your ideas.

[eluser]alekz[/eluser]
Hi, i made a simple controller/function based login by group...
this is an improved version
i made this using ideas of other ACL projects, is simple and effective, this is an example of use:
group_id type
-------------------
1 Admin
2 Publisher
3 Subscriber
add this to the of redux_auth.php config file
Code:
//----------------------------------------
//
//  Permissions begin here
//
//----------------------------------------
$config['auth']['permissions']['/controller1/function1'] = array(1, 2);
$config['auth']['permissions']['/controller1/function2'] = array(1, 3);
$config['auth']['permissions']['/controller2/'] = array(3);

we are giving access to id_groups 1 and 2 to the controller1/function1
we are giving access to id_groups 1 and 3 to the controller1/function2
we are giving access to id_group 3 to the controller2 and all their functions

if you want that everybody that is logged in, use your controller/function just need to do this.
Code:
$config['auth']['permissions']['/controller2/'] = 0;


Put this three lines of code, in every constructor of your controllers

Code:
class Controller1 extends Controller()
{
    function Controller1()   //this is the constructor
    {
        parent::Controller();                              //you just need to put
        if(!$this->redux_auth->has_permissions())  //this three lines
            redirect('');                                  //of code...
        
    }
}

So just put this code in every controller of your project to protect it by controller or by function, and only will be accessed by the groups you want

if you want than a controller/function be accessed by everybody just dont write it in the config file...


to use this you need to add this to redux_auth.php library after logged_in() function
Code:
protected function _get_permissions($group_ids)
{
    if($this->ci->session->userdata('id'))  //check if is logged....
    {
        if($group_ids[0] != 0)
        {
            return $var = (in_array($this->ci->session->userdata('group_id'), $group_ids)) ? true : false; //check if the group
        }
        else return true;
    }
    else
    return false;                
}

public function has_permissions()
{
    $controller = '/'.$this->ci->uri->rsegment(1).'/';
        $function = $controller.$this->ci->uri->rsegment(2);
    if(isset($this->permissions[$controller]))
        return $this->_get_permissions($this->permissions[$controller]);
    else if(isset($this->permissions[$function]))
        return $this->_get_permissions($this->permissions[$function]);
    else return -1;
}
and add this line in function _login
Code:
protected function _login ($users, $banned, $email)
{
    $i = $this->ci->db->select($users.'.password, '.
                               $users.'.hash, '.
                               $users.'.id, '.
                               $users.'.activation_code, '.
                               $users.'.group_id, '. // add this line
                               $banned.'.reason')    
    ->from($users)
    ->join($banned, $users.'.banned_id = '.$banned.'.id', 'left')
    ->where($users.'.email', $email)
    ->limit(1)
    ->get();
    return $var = ($i->num_rows() > 0) ? $i->row() : false;
}
and add this line in the login function to set in the session the group_id after successful login
Code:
public function login ($email, $password)
{
//.....
//....
//.....
if ($password === $result->password)
{
    $this->ci->session->set_userdata(array('id'=> $result->id));
    $this->ci->session->set_userdata(array('group_id'=> $result->group_id));    //add this line
    return true;
}
//....
//....

i hope this can help you, this is simple but effective for small applications...

sorry for my english Tongue

Best Regards from Mexico...

[eluser]jonnyleeharris[/eluser]
Looks like a useful addition you posted above. I'll probably implement that into my new project.

Could anyone post the logic of how to ban a user, and when they are banned what will happen when they try to login? Looked in the library and there doesn't seem to be anything to ban users, yet the ban fields are checked and passed around in SQL queries - not sure what's going on there.

Thanks.

[eluser]Isern Palaus[/eluser]
Hello,

I was trying your amazing library and I have noted that the "secure" example was not working. I don't know if this has been commented yet but then I put my effort to solve the problem.

I have added a new protected function inside the redux_auth_db class basing on the _get_group() one's.

Code:
/**
         *  _get_username
         *
         * @access protected
         * @param void
         * @return bool/string
         */
        protected function _get_username ($users,$where)
        {
            $i = $this->ci->db->select('id,username')
            ->from($users)
            ->where('id',$where)
            ->limit(1)
            ->get();
            
            return $var = ($i->num_rows() > 0) ? $i->row()->username : false;
        }

And then, in the redux_auth class, I have added this:

Code:
/**
         * get_username
         *
         * @access public
         * @param string $id Users id
         * @return string
         */
        public function get_username($id) {return $this->_get_username($this->users_table, $id); }

Also, in the user.php example, the $data1['group'] variable was commented and pointing to $this->redux_auth->get_group();. Looking in the get_group() function I've seen that it's extremely necessary pass the ID to get the group and not the e-mail and the the simple change for:

Code:
$data1['group'] = $this->redux_auth->get_group($this->session->userdata('id'));

Worked...

I am not a expert programmer but I also try to help others.

Best wishes for the author, this is an amazing class and sorry for my school english.

Regards,
-- Isern Palaus




Theme © iAndrew 2016 - Forum software by © MyBB