Welcome Guest, Not a member yet? Register   Sign In
Callback "Password Check" Problem...
#17

[eluser]Unknown[/eluser]
Hi Ortonruk
I have same problem like you exactly with almost same code.
Whatever I type password in, l can go though the login process. It seems like my callback_password_check function is not working.
I also had 2 same hashing codes (I copied and pasted it from somewhere) so I delete it one of hashing codes in both signup controller and login controller.
I signed up new and tried to login in again. But I still face the same issue

So how did you solve it? By removing re-hashing code?

It's couple months ago thread butI hope you see it.

Here is my code:
Code:
<?php

class C_account extends CI_Controller
{
    
    function C_account()
    {
        parent::__construct();
        $this->load->helper(array('html','form'));
        $this->load->library(array('form_validation', 'encrypt'));
        $this->_salt = "123456789987654321";
    }
    

    function login()
    {
        $this->form_validation->set_rules('email', 'Email', 'trim|xss_clean|required|callback_email_check');
        $this->form_validation->set_rules('password', 'Password', 'trim|xss_clean|required|min_length[4]|max_length[12]|callback_password_check');
        $this->_email = $this->input->post('email');
        //Just for debbuging
        //$data['pw0'] = "pw0:".$this->input->post('password');
        $this->_password = sha1($this->_salt . $this->input->post('password'));
        $data['pw'] = $this->_password;
        
        if($this->form_validation->run() == FALSE)
        {
            $this->load->view('v_login', $data);
        }
        else
        {
            //Just for debbuging
            //$data['pw2'] = $this->password_check();
            $this->load->view('test', $data);
            $this->load->view('test2');
        }
    }
    
    function email_check()
    {
        $query = $this->db->get_where('users', array('email' => $this->_email));
        
        if($query->num_rows() > 0)
        {
            return TRUE;
        }
        $this->form_validation->set_message('email_check', 'The username is not in database!');
        return FALSE;
    }
    
    function password_check()
    {
        $this->db->where('email', $this->_email);
        $query = $this->db->get('users');
        $result = $query->row_array();
        
        if($query->num_rows() == 0)
        {
            $this->form_validation->set_message('password_check', 'The password is wrong.');
            return FALSE;
        }
        if($result['password'] == $this->_password)
        {
            return TRUE;
        }
    }

}
?>


Messages In This Thread
Callback "Password Check" Problem... - by El Forum - 02-15-2011, 08:28 AM
Callback "Password Check" Problem... - by El Forum - 02-15-2011, 09:18 AM
Callback "Password Check" Problem... - by El Forum - 02-15-2011, 09:22 AM
Callback "Password Check" Problem... - by El Forum - 02-15-2011, 10:14 AM
Callback "Password Check" Problem... - by El Forum - 02-15-2011, 10:19 AM
Callback "Password Check" Problem... - by El Forum - 02-15-2011, 10:31 AM
Callback "Password Check" Problem... - by El Forum - 02-15-2011, 10:39 AM
Callback "Password Check" Problem... - by El Forum - 02-15-2011, 11:06 AM
Callback "Password Check" Problem... - by El Forum - 02-15-2011, 11:17 AM
Callback "Password Check" Problem... - by El Forum - 02-15-2011, 11:34 AM
Callback "Password Check" Problem... - by El Forum - 02-15-2011, 11:40 AM
Callback "Password Check" Problem... - by El Forum - 02-15-2011, 11:45 AM
Callback "Password Check" Problem... - by El Forum - 02-15-2011, 12:22 PM
Callback "Password Check" Problem... - by El Forum - 02-15-2011, 12:36 PM
Callback "Password Check" Problem... - by El Forum - 02-15-2011, 01:22 PM
Callback "Password Check" Problem... - by El Forum - 02-15-2011, 02:59 PM
Callback "Password Check" Problem... - by El Forum - 04-16-2011, 02:26 PM
Callback "Password Check" Problem... - by El Forum - 04-16-2011, 03:22 PM



Theme © iAndrew 2016 - Forum software by © MyBB