【发布时间】:2011-08-06 19:23:47
【问题描述】:
对于我客户的网站,我有一个管理部分——唯一的问题是我的管理路由似乎没有密码保护。我在如何设置用户系统的教程中添加了管理员保护,并在 app_controller.php 中放置了以下代码:
function beforeFilter() {
// if an admin route is requested and not logged in
$user = $this->Session->read('User');
if(isset($this->params['admin']) && $this->params['admin'] && is_null($user)) {
// set Flash and redirect to login page
$this->Session->setFlash('You need to be logged in for that action.','default',array('class'=>'flash_bad'));
$this->redirect(array('controller'=>'users','action'=>'login','admin'=>FALSE));
}
}
& 在我的 app/config/routes.php 我有这个:
Router::connect('/login', array('controller' => 'users', 'action' => 'login'));
Router::connect('/admin/logout', array('controller' => 'users', 'action' => 'logout'));
我很确定这是为了保护而遗漏了一些东西。
我仍然可以在不登录的情况下访问其他管理区域,即 theowlhouse.com.au/admin/bookings。
我做错了什么?用户模型的管理页面是唯一受保护的页面。
谢谢:)
【问题讨论】:
-
你用的什么教程?可以发个链接吗?
标签: cakephp routing admin authentication