Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/260.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 离子认证&;Codeigniter:新用户登录时循环重定向_Php_Mysql_Codeigniter_Ion Auth - Fatal编程技术网

Php 离子认证&;Codeigniter:新用户登录时循环重定向

Php 离子认证&;Codeigniter:新用户登录时循环重定向,php,mysql,codeigniter,ion-auth,Php,Mysql,Codeigniter,Ion Auth,我是Codeigniter的常客,它已经到了我必须开始查看库以获取登录/忘记密码的地步,所以我决定使用Ion Auth 我设置了这个-工作正常,尝试了已经设置好的管理员帐户,一切正常 现在,当我以管理员身份登录并创建一个新用户时,数据被添加到数据库中,页面从“创建用户”重定向到欢迎页面。但是如果我注销并使用这些新的详细信息登录,页面将变为空白,重新加载栏将变得疯狂!如果有意义的话,url栏看起来会转到欢迎页面,但不会加载任何内容 我还检查了我的控制台上的firebug和php日志错误,什么都没有

我是Codeigniter的常客,它已经到了我必须开始查看库以获取登录/忘记密码的地步,所以我决定使用Ion Auth

我设置了这个-工作正常,尝试了已经设置好的管理员帐户,一切正常

现在,当我以管理员身份登录并创建一个新用户时,数据被添加到数据库中,页面从“创建用户”重定向到欢迎页面。但是如果我注销并使用这些新的详细信息登录,页面将变为空白,重新加载栏将变得疯狂!如果有意义的话,url栏看起来会转到欢迎页面,但不会加载任何内容

我还检查了我的控制台上的firebug和php日志错误,什么都没有

我已经检查了我的数据库,当用户被添加时,密码已经被散列,但在salt列中它被归类为NULL,而默认帐户已经设置了散列码?-这可能与此有关吗

编辑:我现在已经修改了代码,但是当它没有被触碰的时候仍然不起作用,所以只有在代码中的编辑是删除表,在auth控制器中的函数是login、create\u user和logout

当admin@admin.com用户登录后会加载页面,仅加载其他“新”帐户

谢谢

    //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);
        }
    }
}

解决:这是谷歌Chrome的一个bug,我不得不更新系统和浏览器。同样为了储存盐,我在ion_auth配置文件中更改了一些设置,这是Google Chrome的一个错误,我不得不更新系统和浏览器。此外,为了存储SALT,我在登录后更改了ion_auth config文件中的一些设置

,您要将用户重定向到哪个页面?如果它是一个页面,您确实有另一个重定向,那么这种情况可能会发生。请尽可能多地共享代码。