2013-06-14 1 views
0

인증에 Ion Auth를 사용하고 있으며 유효성 검사 오류를 반환하는 데 어려움이 있습니다. login(); 함수는 예상대로 반환하며 register();을 실행하면 올바르게 리디렉션되지만 오류는 반환되지 않습니다.Codeigniter Ion Auth register()가 오류를 반환하지 않음

양식 유효성 검사 :

$this->load->library('form_validation', array(), 'register_form'); 
$this->register_form->set_rules('first_name', $this->lang->line('create_user_validation_fname_label'), 'required|xss_clean'); 
$this->register_form->set_rules('last_name', $this->lang->line('create_user_validation_lname_label'), 'required|xss_clean'); 
$this->register_form->set_rules('email', $this->lang->line('create_user_validation_email_label'), 'required|valid_email'); 
$this->register_form->set_rules('phone', $this->lang->line('create_user_validation_phone_label'), 'required|xss_clean'); 
$this->register_form->set_rules('company', $this->lang->line('create_user_validation_company_label'), 'required|xss_clean'); 
$this->register_form->set_rules('password', $this->lang->line('create_user_validation_password_label'), 'required|min_length[' . $this->config->item('min_password_length', 'ion_auth') . ']|max_length[' . $this->config->item('max_password_length', 'ion_auth') . ']|matches[password_confirm]'); 
$this->register_form->set_rules('password_confirm', $this->lang->line('create_user_validation_password_confirm_label'), 'required'); 

등록 :

if($this->register_form->run() == true){ 
    $username = strtolower($this->input->post('first_name')) . ' ' . strtolower($this->input->post('last_name')); 
    $email = $this->input->post('email'); 
    $password = $this->input->post('password'); 

    $additional_data = array(
     'first_name' => $this->input->post('first_name'), 
     'last_name' => $this->input->post('last_name'), 
     'company' => $this->input->post('company'), 
     'phone'  => $this->input->post('phone'), 
    ); 

    if($this->ion_auth->register($username, $password, $email, $additional_data)){ 
     $this->ion_auth->set_message_delimiters('',''); 
     $this->session->set_flashdata('register_message', $this->ion_auth->messages()); 
     redirect('home/index', 'refresh'); 
    }else{ 
     $this->ion_auth->set_error_delimiters('',''); 
     $this->session->set_flashdata('register_error', $this->ion_auth->errors()); 
     redirect('home/index', 'refresh'); 
    } 
} 

내보기로 플래시 데이터를 전달하고있어 방법이 있습니다 :

$this->data['register_message'] = $this->session->flashdata('register_message'); 
$this->data['register_error'] = (validation_errors()) ? validation_errors() : $this->session->flashdata('register_error'); 

가에서와 $register_error을 울리는 내 보기, 나는 아무것도 얻지 않고 세션 객체를과 함께 인쇄 할 때210 register();을 실행 한 후 user_data 배열이 비어 있습니다. 빈 필드가있는 register();을 실행 중이므로 오류가 발생해야합니다. 어떤 제안?

+0

$this->data['register_error'] = (validation_errors()) ? validation_errors() : $this->session->flashdata('register_error'); 

변경은 어디에서'$ this-> 데이터 [ 'register_message']'을 설정하는? if ($ this-> register_form-> run() == true) {'또는 if() 아래에 코드가 있습니까? – Jeemusu

+0

네, if ($ this-> register_form-> run() == true) {'아래의'if' 문에서'$ this-> data [ 'register_message']'를 설정하고 있습니다. 그건 문제가 아니에요, 나는'($ this-> register_form-> run() == true) {'가 form submit에서 실행되고 있지 않다는 것을 발견했습니다. – Dan

+0

어떻게 실행되지 않는다는 뜻입니까? 유효성 검사 오류가 있으면 false를 반환하므로 실행되지 않습니다. 전체 register() 메소드를 게시하는 것이 좋습니다. – Jeemusu

답변

0

CodeIgniter "flashdata"는 다음 서버 요청에만 사용할 수 있으며 자동으로 삭제됩니다.

왜 세션 데이터에서 찾을 수 없습니까? 추가 keep_flashdata 요청을 통해 flashdata 변수를 보존 할 수 있습니다.

$this->session->keep_flashdata('item'); 

이 줄에는 닫는 대괄호 오류가 있습니다.

$this->data['register_error'] = (validation_errors() ? validation_errors() : $this->session->flashdata('register_error'));