Cakedc.users =>始终重定向到首页 [英] Cakedc.users => always redirect to homepage

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

问题描述

我正在使用全新的Cakephp安装上的"CakeDC/Users"插件. 我有两个控制器:PagesController.php,CardsController.php. Pages有1个操作(测试版是首页),Cards有两个操作(索引和单个操作).

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

推荐答案

没关系,我已替换:

'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 =>始终重定向到首页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆