【发布时间】:2015-10-28 05:43:09
【问题描述】:
我在我的 UsersController 中创建了一个管理员登录功能,它工作正常,我在我的 routes.php 文件中为管理员路由创建了规则,我的 routes.php 管理员例程代码如下
Router::prefix('admin', function ($routes) {
// All routes here will be prefixed with `/admin`
// And have the prefix => admin route element added.
$routes->connect('/', ['controller' => 'Users', 'action' => 'login']);
});
我的用户控制器功能在下面
function login() {
$this->set("title_for_layout", "Login to your account");
$user = $this->Users->newEntity();
if ($this->request->is('post',"put")) {
if(!empty($this->request->data)){
$user = $this->Auth->identify();
if ($user) {
$this->Auth->setUser($user);
return $this->redirect(['controller'=>'users','action'=>'dashboard']);
}
}
}
$this->set(compact("user"));
$this->viewBuilder()->layout('login');
}
如上所示登录后的代码我将管理员用户重定向到仪表板但当我登录时它总是显示错误找不到路由匹配,如图所示
请告诉我我应该怎么做才能解决这个问题,因为蛋糕 2.0 我们只为管理员和前端添加一个规则,然后使用重定向或 href 链接重定向到其他控制器和操作,所以我有什么方法吗为路由创建了上述规则,它不会自动重定向到用户控制仪表板功能,或者我必须为每个操作创建路由
谢谢
【问题讨论】:
标签: routing cakephp-3.0