2013-02-07 2 views
-1

을 자주 사용하는 사용자입니다. 로그인을 위해 라이브러리를 살펴보아야 만했습니다. 암호를 잊어 버렸기 때문에 Ion을 사용하기로 결정했습니다. Auth.Ion Auth & Codeigniter : 새로운 사용자 로그인

나는 이것을 잘 설정했다. 이미 설정 한 관리자 계정을 사용해 보았으므로 괜찮다.

이제 admin으로 로그인 한 다음 새 사용자를 만들면 데이터가 데이터베이스에 추가되고 페이지가 "create-user"에서 시작 페이지로 리디렉션됩니다. 그러나 나가이 새로운 세부 사항을 가진 로그 아웃하고 로그인하는 경우에, 페이지는 비게되고 재 장전 막대는 미쳤다! URL이 환영 페이지로 이동하는 것처럼 보이지만 의미가 있지만 아무것도로드하지 않는 것처럼 보입니다.

또한 내 콘솔을 파이어 버그 및 PHP 로그 오류로 확인했는데 아무 것도 표시하지 않았습니다.

데이터베이스를 검사했는데 사용자가 추가되면 비밀번호가 해시되었지만 소금 열에는 이미 기본 계정에 해시 코드가있는 반면 NULL로 분류됩니까? -이게이 일과 관련이있을 수 있니?

EDIT : 코드를 변경했지만 코드를 수정하지 않아도 테이블을 제거 할 수 있으며 인증 컨트롤러에서 로그인, create_user 및 로그 아웃 기능 만 수행됩니다.

그리고 그 안에 [email protected]의 사용자가 로그인 페이지 단지 다른 좋은 "새로운"계정 ..

감사를로드 할 때!

//log the user in 
    function login() { 

     $this->data['title'] = "Login"; 

     $this->form_validation->set_rules('identity', 'Identity', 'required'); 
     $this->form_validation->set_rules('password', 'Password', 'required'); 

     if ($this->form_validation->run() == true) { 

      //check for "remember me" 
      $remember = (bool) $this->input->post('remember'); 

      if ($this->ion_auth->login($this->input->post('identity'), $this->input->post('password'), $remember)) { 

       //if the login is successful 
       //redirect them back to the home page 
       $this->session->set_flashdata('message', $this->ion_auth->messages()); 
       redirect('/', 'refresh'); 
      }else{ 
       //if the login was un-successful 
       //redirect them back to the login page 
       $this->session->set_flashdata('message', $this->ion_auth->errors()); 
       redirect('auth/login', 'refresh'); 
      } 
     }else{ 

      //the user is not logging in so display the login page 
      $this->data['message'] = (validation_errors()) ? validation_errors() : $this->session->flashdata('message'); 

      $this->data['identity'] = array('name' => 'identity', 
       'id' => 'identity', 
       'type' => 'text', 
       'value' => $this->form_validation->set_value('identity'), 
      ); 
      $this->data['password'] = array('name' => 'password', 
       'id' => 'password', 
       'type' => 'password', 
      ); 

      $this->_render_page('auth/login', $this->data); 
     } 
    } 


    //log the user out 
    function logout() { 

     $this->data['title'] = "Logout"; 

     $logout = $this->ion_auth->logout(); 

     $this->session->set_flashdata('message', $this->ion_auth->messages()); 
     redirect('auth/login', 'refresh'); 
    } 



    //create a new user 
    function create_user() { 

     $this->data['title'] = "Create User"; 

     $this->form_validation->set_rules('first_name', 'First Name', 'required|xss_clean'); 
     $this->form_validation->set_rules('last_name', 'Last Name', 'required|xss_clean'); 
     $this->form_validation->set_rules('email', 'Email Address', 'required|valid_email'); 
     $this->form_validation->set_rules('password', 'Password', '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->form_validation->set_rules('password_confirm', 'Password Confirmation', 'required'); 

     if ($this->form_validation->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') 

      ); 
     } 
     if ($this->form_validation->run() == true && $this->ion_auth->register($username, $password, $email, $additional_data)) { 
      //check to see if we are creating the user 
      //redirect them back to the admin page 
      $this->session->set_flashdata('message', $this->ion_auth->messages()); 
      redirect("auth/login", 'refresh'); 
     }else{ 
      //display the create user form 
      //set the flash data error message if there is one 
      $this->data['message'] = (validation_errors() ? validation_errors() : ($this->ion_auth->errors() ? $this->ion_auth->errors() : $this->session->flashdata('message'))); 

      $this->data['first_name'] = array(
       'name' => 'first_name', 
       'id' => 'first_name', 
       'type' => 'text', 
       'value' => $this->form_validation->set_value('first_name'), 
      ); 
      $this->data['last_name'] = array(
       'name' => 'last_name', 
       'id' => 'last_name', 
       'type' => 'text', 
       'value' => $this->form_validation->set_value('last_name'), 
      ); 
      $this->data['email'] = array(
       'name' => 'email', 
       'id' => 'email', 
       'type' => 'text', 
       'value' => $this->form_validation->set_value('email'), 
      ); 
      $this->data['password'] = array(
       'name' => 'password', 
       'id' => 'password', 
       'type' => 'password', 
       'value' => $this->form_validation->set_value('password'), 
      ); 
      $this->data['password_confirm'] = array(
       'name' => 'password_confirm', 
       'id' => 'password_confirm', 
       'type' => 'password', 
       'value' => $this->form_validation->set_value('password_confirm'), 
      ); 

      $this->_render_page('auth/create_user', $this->data); 
     } 
    } 

    function _render_page($view, $data=null, $render=false) { 

     $this->viewdata = (empty($data)) ? $this->data: $data; 

     $view_html = $this->load->view($view, $this->viewdata, $render); 

     if (!$render) return $view_html; 
    } 

} 

시작 페이지 컨트롤러

class Welcome extends CI_Controller { 

    function __construct() { 

     parent::__construct(); 
     $this->load->library('ion_auth'); 
     $this->load->library('session'); 
     $this->load->library('form_validation'); 
     $this->load->helper('url'); 
    } 


     public function index() { 

     if (!$this->ion_auth->logged_in()) { 
      redirect('auth/login', 'refresh'); 

     }elseif (!$this->ion_auth->is_admin()) { 
      redirect('/', 'refresh'); 
     }else{ 
      $this->data['message'] = (validation_errors()) ? validation_errors() : $this->session->flashdata('message'); 
      $this->_render_page('auth/welcome', $this->data); 
     } 
    } 
} 

해결 :이 난 시스템과 brwser를 업데이트 했어 구글 크롬 버그이었다. 또한 소금을 저장하는 난 내 ion_auth 설정 파일

+0

로그인 후 어떤 페이지로 사용자를 리디렉션합니까? 다른 리디렉션이있는 페이지 인 경우 이러한 상황이 발생할 수 있습니다. 최대한 많은 코드를 공유하십시오. – Rana

답변

0

에서 일부 설정을 변경이 내가 시스템과 브라우저를 업데이트 했어 구글 크롬 버그이었다. 또한 SALT를 저장하기 위해 ion_auth 설정 파일에서 일부 설정을 변경했습니다.

관련 문제