Cakephp简单身份验证教程页面未重定向到当前页面
我开始阅读cakephp教程,我完全按照教程所示复制源代码 我已经完成了博客教程,看起来一切都不错,现在我开始学习“简单身份验证和授权应用程序”(Simple Authentication and Authorization Application)教程,但是遇到了这个问题Cakephp简单身份验证教程页面未重定向到当前页面,cakephp,Cakephp,我开始阅读cakephp教程,我完全按照教程所示复制源代码 我已经完成了博客教程,看起来一切都不错,现在我开始学习“简单身份验证和授权应用程序”(Simple Authentication and Authorization Application)教程,但是遇到了这个问题 “添加”页面将很好地加载: “../app/webroot/index.php/Users/add” 点击提交后,它会将我重定向到这个url(带有附加的“Users”字符串)并显示一条错误消息 “../app/webroot
应用控制器
class AppController extends Controller {
public $components = array(
'Session',
'Auth' => array(
'loginRedirect' => array('controller' => 'posts', 'action' => 'index'),
'logoutRedirect' => array('controller' => 'pages', 'action' => 'display', 'home'),
'authorize' => array('Controller') // Added this line
)
);
public function beforeFilter() {
$this->Auth->allow('index', 'view');
}
public function isAuthorized($user) {
// Admin can access every action
if (isset($user['role']) && $user['role'] === 'admin') {
return true;
}
// Default deny
return false;
}
}
因为我仍然不能发表评论,我会在这里告诉你,如果我知道的话,我会编辑这个答案 在
AppController.php
中显示您的AuthComponent
配置
编辑:
答案在下面的评论中。:) 请提供login.ctp文件或用于登录的视图文件所在的位置。副本如教程所示:“”。查找“”,这部分代码就是我登录时使用的代码。ctpTry通过本教程,它真的很棒:。还有一件事。。。检查mod_重写。它工作了吗?终于让mod_rewrite工作了,然后我发现:这项工作使它工作了,我想,只是通过别名地址,仍然是一个不可能的实际长地址“../app/webroot/index.php/Users/add”。我们将尝试教程。谢谢。
/app/webroot/index.php/Users/add
?这可能是一个url重写问题:您是否遵循了url重写教程:
class AppController extends Controller {
public $components = array(
'Session',
'Auth' => array(
'loginRedirect' => array('controller' => 'posts', 'action' => 'index'),
'logoutRedirect' => array('controller' => 'pages', 'action' => 'display', 'home'),
'authorize' => array('Controller') // Added this line
)
);
public function beforeFilter() {
$this->Auth->allow('index', 'view');
}
public function isAuthorized($user) {
// Admin can access every action
if (isset($user['role']) && $user['role'] === 'admin') {
return true;
}
// Default deny
return false;
}
}