Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
[es] Ejemplo de MY_Controller.php usando ion_auth como librería de Auth
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Home extends Admin_Controller {
public function index()
{
//$this->load->view('admin/_header', $data);
$this->load->view('admin/_header');
$this->load->view('admin/home');
$this->load->view('admin/_footer');
}
}
/* End of file home.php */
/* Location: ./application/controllers/home.php */
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Admin_Controller extends CI_Controller {
protected $the_user;
public function __construct() {
parent::__construct();
if($this->ion_auth->is_admin()) {
$data->the_user = $this->ion_auth->user()->row();
$this->the_user = $data->the_user;
$this->load->vars($data);
}
else {
redirect('/');
}
}
}
class User_Controller extends CI_Controller {
protected $the_user;
public function __construct() {
parent::__construct();
if($this->ion_auth->is_group('user')) {
$data->the_user = $this->ion_auth->user()->row();
$this->the_user = $data->the_user;
$this->load->vars($data);
}
else {
redirect('/');
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.