認証スクリプトを作成する時間を節約するために、tank auth をインストールしました。
HMVC を使用しているため、tank auth には独自のモジュール (modules/auth) があります。
ログイン スクリプトを使用して他のモジュール (/admin、/members など) を保護するにはどうすればよいですか??
私が読んだことから、次のようなことをする必要があります:
modules::run('auth/is_logged_in');
私の認証コントローラーは次のようになります。
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
class Auth extends MX_Controller
{
function __construct()
{
parent::__construct();
$this->load->helper(array('form', 'url'));
$this->load->library('form_validation');
//$this->load->library('security');
$this->load->library('tank_auth');
$this->lang->load('tank_auth');
}
function index()
{
if ($message = $this->session->flashdata('message')) {
//$this->load->view('auth/auth/general_message', array('message' => $message));
$main_content = 'auth/auth/general_message';
$this->load->view('includes/template', array('message' => $message, 'main_content' =>$main_content));
} else {
redirect('auth/login/');
}
}
/**
* Login user on the site
*
* @return void
*/
function login()
{
if ($this->tank_auth->is_logged_in()) { // logged in
redirect('admin');
} elseif ($this->tank_auth->is_logged_in(FALSE)) { // logged in, not activated
redirect('auth/send_again/');........
ログインスクリプトで保護したいコントローラ/モジュール:
<?php
if (!defined('BASEPATH'))
exit('No direct script access allowed');
class Admin extends MX_Controller {
public function __construct(){
parent::__construct();
modules::run('auth/auth/login');
}
上記はうまくいかないようですか?私は何が欠けていますか?