首先,我想为我的英语道歉,=)。我正在制作一个Web应用程序但是当将程序流重定向到另一个controllador时,我收到此错误:" 404 Page Not Not Found"。正如我在其他帖子中读到的那样,类和文件都是大写的,而且可能不是。提前谢谢。
这是调用" Activity"的主控制器(Auth Controller)。使用"重定向":
class Auth extends CI_Controller {
public function __construct() {
parent::__construct();
}
public function index() {
redirect('auth/login');
}
public function login() {
if (!$this->input->post())
{
$this->load->view('templates/main_template', array(
'title' => 'Login',
'header' => $this->load->view('templates/header', null, TRUE),
'content' => $this->load->view('pages/login', null, TRUE),
'footer' => $this->load->view('templates/footer', null, TRUE)
));
return;
}
$this->form_validation->set_rules('useremail', 'Useremail', 'trim|required|xss_clean'); // trim: quita espacios; required: campo requerido; xss_clean: elimina posibles inyecciones sql; callback_user_auth: otras funciones y llamadas, en este caso llamada a funciónq que autentifica al usuario
$this->form_validation->set_rules('password', 'Password', 'trim|required|xss_clean|callback_user_auth'); // |callback_user_auth
if ($this->form_validation->run() == FALSE)
{
// LOGIN VIEW (home)
$this->load->view('templates/main_template', array(
'title' => 'Login',
'header' => $this->load->view('templates/header', null, TRUE),
'content' => $this->load->view('pages/login', null, TRUE),
'footer' => $this->load->view('templates/footer', null, TRUE)
));;
} else {
redirect('activity/list_actividades');
}
}
public function user_auth($password) {
$useremail = $this->input->post('useremail');
$user = $this->User_model->authenticate($useremail, $password);
if ($user)
{
// valid user, set session data
$this->session->logged_in = array(
'useremail' => $user->email,
'username' => $user->name,
'group' => $user->group // CAMBIO EN LA BASE DE DATOS
); // GROUP POR ADMIN. DEPENDIENDO DEL GRUPO SE TIENEN UNOS PERMISOS U OTROS
return TRUE;
}
$this->form_validation->set_message('user_auth', 'Invalid username or password');
return FALSE;
}
public function logout() {
unset($_SESSION['logged_in']);
redirect('auth/login');
}
活动控制器:
class Activity extends CI_Controller {
public function __construct() {
parent::__construct();
// check for the session here... in theory
}
public function index() {
redirect('auth/login');
}
public function list_actividades () {
$this->load->model('Activity_model');
$data['actividades'] = $this->Activity_model->getAll();
$data['grupo_usuario'] = $this->session->logged_in['group'];
$this->load->view('templates/main_template', array(
'title' => 'Lista de Actividades',
'header' => $this->load->view('templates/header', null, TRUE),
'content' => $this->load->view('templates/lista_actividades', $data, TRUE),
'footer' => $this->load->view('templates/footer', null, TRUE)
));
}
答案 0 :(得分:0)
你的函数list_actividades中有一个* / CodeIgniter可能会忽略错误,但由于它无法读取类,导致404
答案 1 :(得分:0)
好的,最后是当你使用授权钩子时,你必须在acl.php文件中注册授权地址。