0

我正在尝试更改消息

您无权访问该位置。

使用 cakephp 3.1 的 cakedc/users 插件,但我找不到路。

这是我在 src/Controller/AppController 中的配置:

public function initialize()
    {
        parent::initialize();
        $this->loadComponent('Flash');
        $this->loadComponent('CakeDC/Users.UsersAuth', [
         'authError' => 'Did you really think you are allowed to see that?',
      ]
     );
    }

但仍然是消息:

您无权访问该位置。

我做错了什么?

谢谢你。

4

3 回答 3

5

我做错了什么?

您没有按预期配置插件。如文档中所述:

[...]

该插件是通过 Configure 类配置的。检查vendor/cakedc/users/config/users.php所有配置键的完整列表。

https://github.com/CakeDC/users/blob/3.1.1/Docs/Documentation/Configuration.md

要配置身份验证组件选项,请使用Auth链接文档中描述的配置文件中的密钥

$config = [
    // ...

    'Auth' => [
        'authError' => 'Did you really think you are allowed to see that?',
        // ...
    ],

    // ...
];

或通过Configure::write()

Configure::write('Auth.authError', 'Did you really think you are allowed to see that?');
于 2015-10-10T22:38:30.627 回答
0

这是我在 src/Controller/AppController 中的配置:

public function initialize()
{
    parent::initialize();

    $this->loadComponent('RequestHandler');
    $this->loadComponent('Flash');
    $this->loadComponent('Auth', [
        'authError'    => 'Você não está autorizado a acessar este conteúdo!',
        'authorize'    => ['Controller'],
        //
    ]);
    // 
}
于 2017-03-27T13:34:31.060 回答
-2

尝试在第 454 行更改文件 vendor/cakephp/cakephp/src/Controller/Component/AuthComponent.php,即authError密钥。

'authError' => __d('cake', 'You are not authorized to access that location.')
于 2016-01-27T12:02:13.910 回答