首页 > 解决方案 > Codeigniter ion auth login make 多个用户 if 语句错误

问题描述

我在 System CI 中创建了更多用户,我尝试让 Auth_controller.php 使用 if 语句处理它......当我们使用 if 语句登录并尝试登录用户“gudang”时,它只是获取$this->load->view('sales/header'); $this->load->view('admin/dashboard');销售语句,这个语句“gudang”无法加载这种观点

public function index()
{   if (!$this->ion_auth->logged_in()){
        redirect('auth/login', 'refresh');
    }
    elseif ($this->ion_auth->is_admin()){
        //return show_error('You must be an administrator to view this page.');
        // set the flash data error message if there is one
        $this->data['message'] = (validation_errors()) ? validation_errors() : $this->session->flashdata('message');
        $this->data['users'] = $this->ion_auth->users()->result();
        foreach ($this->data['users'] as $k => $user)
        {
    $this->data['users'][$k]->groups = $this->ion_auth->get_users_groups($user->id)->result();
        }
        $this->_render_page('admin/lte/header', $this->data);
        $this->_render_page('admin/dashboard', $this->data);
        // $this->_render_page('admin/lte/footer', $this->data);
    }elseif ($this->ion_auth->get_users_groups($user->id)==='Sales'){
        $this->load->view('sales/header');
        $this->load->view('admin/dashboard');
    }elseif ($this->data['users'] = $this->ion_auth->users('gudang')){
        $this->load->view('gudang/header');
        $this->load->view('admin/dashboard');
    }else{
        redirect('auth/login', 'refresh');
    }
}

标签: codeigniterif-statementcodeigniter-3ion-auth

解决方案


推荐阅读