Codeigniter with ion_auth - 无法登录,无需验证

时间:2016-01-20 15:55:05

标签: php codeigniter ion-auth

将codeigniter与ion_auth一起使用。在登录页面上,似乎验证无效; " if($ this-> form_validation-> run()== true)"始终返回false,但表单中不显示任何错误消息。这是直接开箱即用的控制器和视图,我没有编辑任何东西。不知道如何调试这个;任何想法?

这是正在运行的功能,但不起作用:

function login()
{
    $this->data['title'] = "Login";

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

    if ($this->form_validation->run() == true)
    {
        // check to see if the user is logging in
        // 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'); // use redirects instead of loading views for compatibility with MY_Controller libraries
        }
    }
    else
    {
        // the user is not logging in so display the login page
        // set the flash data error message if there is one
        $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);
    }
}

1 个答案:

答案 0 :(得分:0)

该网页发布到了错误的位置。咄。