vendredi 21 septembre 2018

Codeigniter ion auth login make multiple user if statement error

I make more user in System CI, and i try make Auth_controller.php use if statement handle it, but when get spesific user and get

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

Aucun commentaire:

Enregistrer un commentaire