1

CI認証にionauthを使用しています。登録後に自動ログインで問題が発生しました。レジスターに問題はなく、すべてのデータが挿入され、ログインフォームでログインできます。ただし、ユーザーが登録した後はホームページにリダイレクトされません。

以下は私のコードです。誰でも見てもらえますか?

if ( $this->form_validation->run() == TRUE )
        {   
            //if form validation not false, password var
            $username = $this->input->post('email');
            $password = $this->input->post('password');
            $email = $this->input->post('email');
            $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 home page
            $this->session->set_flashdata('msg', "User Created");
            redirect("auth/home", 'refresh');
        }
        else
        {
            $this->session->set_flashdata('msg', validation_errors('<div>','</div>'));
            redirect('auth/index','refresh');
        }
4

1 に答える 1

3

これは、ユーザーが「登録」されているが、「ログイン」されていないためです。登録後、リダイレクトする前に、手動でログインする必要があります。

        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 home page            
               $this->session->set_flashdata('msg', "User Created");   
              // ***DO MANUAL LOGIN HERE WITH ION_AUTH***
              redirect("auth/home", 'refresh');     
          } 
于 2012-07-07T22:47:24.537 に答える