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

[eluser]coldKingdom[/eluser]
Absolutely

Code:
// Set Required Fields.
        $this->ci->auth_model->set($data);

        
        if ( !empty($this->optional) )
        {
            // Loop through each additional column and
            // map them to a input with the same key
            // and add it to an array.
            foreach( $this->optional as $key => $value)
            {
    
                if ( !$this->ci->db->field_exists($key, $this->usertable) )
                {
                    $fields = array($key => $value);
                    $this->ci->dbforge->add_column($this->usertable, $fields);
                }
                $optional[$key] = $this->ci->input->post($key);
            }
    
            // Set Optional Fields.
            $this->ci->auth_model->set($optional);
        }

        // No email validation required.
        if ( !$this->emailver )
        {
            // Register.
            $this->ci->auth_model->insert($this->usertable);
#42

[eluser]Popcorn[/eluser]
Hmm, strange. I thought it was the fix I just uploaded that was causing this, but I've tested it locally and it's fine. Have you correctly set the config/auth.php table names?
#43

[eluser]coldKingdom[/eluser]
Yes, if I set the custom colums to empty/null then it works great.

Edit: Just tested to make the columns manually and then it works with the custom fields.
#44

[eluser]Popcorn[/eluser]
Hmm. I'll try and see what's going on with this code. Thanks for bringing this to my attention.

Edit : The columns are generated when the registration function is called so I'm not sure if you knew that or not.
#45

[eluser]coldKingdom[/eluser]
No problem, glad to help (or trying atleast)! Smile
#46

[eluser]coldKingdom[/eluser]
[quote author="Popcorn" date="1204684714"]Hmm. I'll try and see what's going on with this code. Thanks for bringing this to my attention.

Edit : The columns are generated when the registration function is called so I'm not sure if you knew that or not.[/quote]

Yeah, i knew that Smile
#47

[eluser]patbert[/eluser]
Ok, I have been hacking away at this. . .

I really wanted to have the user id number in the session data, so in auth_model.php I created:
Code:
function get_id ($table, $email)
        {  
                $this->db->select($table. '.id');
                $this->db->from($table);
                $this->db->where($table. '.email', $email);

                $i = $this->db->get();

                if ( $i->num_rows() > 0 )
                {  
                        $row = $i->row();
                        return $row->id;
                }  
                return false;

        }

I have no idea if there is a better way to do that, but it works. Then in the library I added a few lines to the login function:
Code:
// If they match then login.
                        if ( $password === $dbpassword )
                        {  
    
                                $id = $this->ci->auth_model->get_id($this->usertable, $email);

                                $data = array(
                                        'email'         => $email,
                                        'id'            => $id,
                                        'logged_in' => 'yes'
                                );  

                                $this->ci->session->set_userdata($data);
                                return true;
                        }

Then you can grab the userid with $this->session->userdata('id')


One thing I cannot get to work is the logout function.

In my controller I have:
Code:
function logout() {
                $this->auth->logout();
                $this->session->set_flashdata('response', 'Have a nice day');
                redirect('blog');
        }
It runs happily enough, but the session is still there after the redirect. Maybe this is an issue on my end?
#48

[eluser]Popcorn[/eluser]
Not sure why that isn't working. My auth logout is only destroying the session, nothing drastic. I'd have to say that's an issue on your end.
#49

[eluser]patbert[/eluser]
It isn't working because I set the flashdata right after the session is destroyed. That some how revives the entire session.

Does that count as a bug in CI? I wonder if there is any way to get around it.
#50

[eluser]Unknown[/eluser]
You can send to cakeowiec[]gmail[]com source file from example site - becouse I don't know how use this class.

Thanks.




Theme © iAndrew 2016 - Forum software by © MyBB