我试着改变消息
您无权访问该位置。
使用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?',
]
);
}
但仍然是消息:
您无权访问该位置。
我做错了什么?
谢谢。
答案 0 :(得分:4)
我做错了什么?
您未按预期配置插件。正如文档中所述:
[...]
该插件通过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?');
答案 1 :(得分:-1)
这是我在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'],
//
]);
//
}
答案 2 :(得分:-2)
尝试更改文件
第454行 vendor / cakephp / cakephp / src / Controller / Component / AuthComponent.php ,authError
键。
'authError' => __d('cake', 'You are not authorized to access that location.')