問題描述
我在新的 Cakephp 安裝中使用插件CakeDC/Users".我有兩個(gè)控制器:PagesController.php、CardsController.php.Pages 有 1 個(gè)操作(Beta,這是主頁),Cards 有 2 個(gè)操作(索引和單項(xiàng)).
I'm using the plugins "CakeDC/Users" on a brain new Cakephp installation. I've got two controllers : PagesController.php, CardsController.php. Pages has 1 action (Beta, it's the homepage), and Cards two actions (index, and single).
這是引導(dǎo)程序中的設(shè)置:
Here is the setup in the bootstrap :
Configure::write('Users.config', ['users']);
Plugin::load('CakeDC/Users', ['routes' => true, 'bootstrap' => true]);
以及config/users.php中插件的配置:
And the configuration of the plugin in config/users.php :
return [
'Users' => [
'Email' => [
'validate' => false
]
],
'Auth' => [
'loginAction' => [
'plugin' => null,
'controller' => 'Members',
'action' => 'login',
'prefix' => null
],
'logoutAction' => [
'plugin' => null,
'controller' => 'Members',
'action' => 'logout',
'prefix' => null
],
'authenticate' => [
'all' => [
'finder' => 'auth',
],
'CakeDC/Users.ApiKey',
'CakeDC/Users.RememberMe',
'Form',
],
'authorize' => [
//'CakeDC/Users.Superuser',
//'CakeDC/Users.SimpleRbac',
],
],
];
我只配置了一個(gè)路由:
$routes->connect('/', ['controller' => 'Pages', 'action' => 'Beta', 'home']);
這是我的 AppController.php :
And here is my AppController.php :
public function initialize()
{
parent::initialize();
$this->loadComponent('Flash');
$this->loadComponent('CakeDC/Users.UsersAuth');
}
主頁被允許:
$this->Auth->allow('beta');
未登錄時(shí),我只能訪問/pages/beta,沒關(guān)系.我可以用插件注冊(cè)、登錄和注銷,這邊沒問題.
When not logged in, I can only access /pages/beta, which is ok. I can register, login, and logout with the plugin, no problem on this side.
登錄后,除了主頁之外,我無法訪問任何其他頁面.如果我到達(dá)/cards/index 或/cards/single,我總是會(huì)重定向到主頁.如果我禁用了插件,頁面訪問就可以了.
Once I'm logged, I can't access any other pages than the homepage. If I got to /cards/index, or /cards/single, I'm always redirect to the homepage. If I disabled the plugin, pages access is ok.
我已經(jīng)堅(jiān)持了一段時(shí)間了,有什么幫助嗎?謝謝,最好的問候
I'm stuck on this since a while now, any help ? Thanks, Best Regards
推薦答案
沒關(guān)系,我已經(jīng)更換了:
Nevermind, I've replaced :
'authorize' => [
//'CakeDC/Users.Superuser',
//'CakeDC/Users.SimpleRbac',
],
作者:
'authorize' => false,
插件默認(rèn)使用授權(quán)組件,所以如果你不打算使用它,你可以設(shè)置false"以確保你沒有問題.或者你必須通過設(shè)置好的設(shè)置來設(shè)置授權(quán)的控制器和動(dòng)作.
The plugin used authorize with a component by default, so if you're not going to use it, you have the set "false" to be sure you don't have issues. Or you have to setup the authorized controllers and actions by setting up the good setup.
謝謝,
這篇關(guān)于Cakedc.users =>總是重定向到主頁的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!