1

我正在使用 ion auth 进行 CI 身份验证。注册后自动登录出现问题。我的注册没有问题,所有数据都已插入,我可以使用我的登录表单登录。但是在用户注册后它不会重定向到主页。

下面是我的代码。任何人都可以看看吗?

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 回答