沃梦达 / 编程问答 / php问题 / 正文

Cakedc.users =>总是重定向到主页

Cakedc.users =gt; always redirect to homepage(Cakedc.users =总是重定向到主页)

本文介绍了Cakedc.users =>总是重定向到主页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在新的 Cakephp 安装中使用插件CakeDC/Users".我有两个控制器:PagesController.php、CardsController.php.Pages 有 1 个操作(Beta,这是主页),Cards 有 2 个操作(索引和单项).

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).

这是引导程序中的设置:

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',
    ],
],

];

我只配置了一个路由:

$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');

未登录时,我只能访问/pages/beta,没关系.我可以用插件注册、登录和注销,这边没问题.

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.

登录后,除了主页之外,我无法访问任何其他页面.如果我到达/cards/index 或/cards/single,我总是会重定向到主页.如果我禁用了插件,页面访问就可以了.

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.

我已经坚持了一段时间了,有什么帮助吗?谢谢,最好的问候

I'm stuck on this since a while now, any help ? Thanks, Best Regards

推荐答案

没关系,我已经更换了:

Nevermind, I've replaced :

'authorize' => [
       //'CakeDC/Users.Superuser',
       //'CakeDC/Users.SimpleRbac',
],

作者:

'authorize' => false,

插件默认使用授权组件,所以如果你不打算使用它,你可以设置false"以确保你没有问题.或者你必须通过设置好的设置来设置授权的控制器和动作.

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.

谢谢,

这篇关于Cakedc.users =>总是重定向到主页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:Cakedc.users =>总是重定向到主页

基础教程推荐