我正在尝试使用 Ion Auth 来保护我网站上的管理区域。
我安装了 Ion Auth(添加表格、复制文件)。
我添加了文件 application/system/core/MY_Controller.php,如下所示:
<?php
class Admin_Controller extends CI_Controller {
//Class-wide variable to store user object in.
protected $the_user;
public function __construct() {
parent::__construct();
if (!$this->ion_auth->is_admin() )
{
redirect('/auth/login');
}
}
}
?>
在管理区域的所有控制器中,我将 CI_Controller 更改为 Admin_Controller,如下所示:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Start extends Admin_Controller
{
public function index()
{
$this->load->view('layout/_header');
$this->load->view('layout/_left');
$this->load->view('admin/start');
$this->load->view('layout/_footer');
}
}
现在我想弄清楚如何创建自己的登录表单,并用我的布局视图包装。
我不知道该怎么做。在 'auth/login' 控制器视图以某种奇怪的方式加载:
$this->_render_page('auth/login', $this->data);
有人可以帮我编写登录表单,这将与我加载视图的方法兼容吗?
我的意思是那个方法:
$this->load->view('layout/_header');
$this->load->view('layout/_left');
$this->load->view('admin/login'); // i want to load login form here
$this->load->view('layout/_footer');