Welcome Guest, Not a member yet? Register   Sign In
Can't set customer form error
#3

You need to validate the login with a callback.
https://www.codeigniter.com/user_guide/l...on-methods

You can modify mine if you want.

PHP Code:
public function login()
{
    
$this->load->helper('form');
    
$this->load->library('form_validation');
    
    
$validation_rules = array(
        array(
            
'field' => 'username',
            
'label' => lang('login_email'),
            
'rules' => array(
                
'trim',
                
'valid_email'
            
)
        ),
        array(
            
'field' => 'password',
            
'label' => lang('login_password'),
            
'rules' => array(
                
'trim',
                
'required',
                array(
'validate_auth', array( $this'_validate_auth' ) )
            )
        )
    );
    
    
$this->form_validation->set_rules$validation_rules );
    
    if( 
$this->form_validation->run() === TRUE )
    {
        return 
TRUE;
    }
    return 
FALSE;
}

// --------------------------------------------------------------

public function _validate_auth()
{
    
$user_email        $this->input->post('username');
    
$user_password    $this->input->post('password');
    
    if( empty(
$user_email) OR empty($user_password) )
    {
        
$this->form_validation->set_message('validate_auth'lang('error_missing_fields'));                
        return 
FALSE;
    }
    
    if( 
$auth_data $this->auth_model->get_auth_data$user_email ) )
    {
        if( 
$auth_data->banned === '1' )
        {
            
$this->form_validation->set_message('validate_auth'lang('error_username_password'));
            return 
FALSE;
        }
        if( ! 
$this->check_password$auth_data->passwd$user_password ) )
        {
            
$this->form_validation->set_message('validate_auth'lang('error_username_password'));
        }
        else
        {
            
// Setup redirection if redirect required
            
$this->redirect_after_login();
                    
            
// Set session cookie and remember me
            
$this->maintain_state$auth_data );
            
            
// Send the auth data back to the controller
            
return TRUE;
        }
    }
    else
    {
        
$this->form_validation->set_message('validate_auth'lang('error_username_password'));
    }
    
    return 
FALSE;

Reply


Messages In This Thread
Can't set customer form error - by randomhacks - 03-07-2018, 01:52 PM
RE: Can't set customer form error - by Marcel - 03-08-2018, 04:05 AM
RE: Can't set customer form error - by jreklund - 03-08-2018, 07:31 AM



Theme © iAndrew 2016 - Forum software by © MyBB