- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
即使用户未登录并尝试打开主页,在被重定向到登录页面后,也会显示 authError。是否有一种优雅的方法来防止这种情况,而无需修改 Auth 组件?这是我加载 Auth 组件的方式(我使用 TinyAuth 作为授权适配器):
$this->loadComponent('Auth', [
'loginAction' => [
'controller' => 'Users',
'action' => 'login'
],
'loginRedirect' => [
'controller' => 'Home',
'action' => 'index'
],
'authError' => 'You dont have permissions for that action',
'authenticate' => [
'Form' => [
'fields' => [
'username' => 'email',
'password' => 'password'
],
'scope' => ['Users.active' => true],
'contain' => ['Roles']
]
],
'authorize' => [
'TinyAuth.Tiny' => [
'roleColumn' => 'role_id',
'rolesTable' => 'Roles',
'multiRole' => true,
'pivotTable' => 'roles_users',
'superAdminRole' => null,
'authorizeByPrefix' => false,
'prefixes' => [],
'allowUser' => false,
'adminPrefix' => null,
'autoClearCache' => true
]
]
]
);
最佳答案
根据 CakePHP's documentation您可以通过将 authError
设置为 false
来防止显示错误消息。
Sometimes, you want to display the authorization error only after the user has already logged-in. You can suppress this message by setting its value to boolean false.
这应该禁用错误消息:
if (!$this->Auth->user()) {
$this->Auth->config('authError', false);
}
关于authentication - CakePHP 3.2 : Prevent authError showing when user is not logged in,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38037777/
我已经在我公司的现有站点内使用 CakePHP 设置了一个有效的 ACL 系统。访问限制非常有效,无权访问站点特定部分的组和单个用户会收到一条 authError 消息,说明他们没有适当的权限。 唯一
我有一个 CakePHP 项目,我在其中修改了“app/config/routes.php”,以便根指向“用户” Controller 的“仪表板”操作。换句话说,这两个 URL 去同一个地方: ht
将 CakePHP 从 2.6.2 更新到 2.7.2 后,我在创建 auth flash 消息时遇到了缺少 key 的错误。如何为默认的 authError 定义元素模板? 因为 SessionCo
我已安装电子邮件包并尝试发送测试邮件,但出现以下错误:AuthError:无效登录 - 535-5.7.8 用户名和密码未接受 我确定凭据正确,并且代码与:https://github.com/ide
即使用户未登录并尝试打开主页,在被重定向到登录页面后,也会显示 authError。是否有一种优雅的方法来防止这种情况,而无需修改 Auth 组件?这是我加载 Auth 组件的方式(我使用 TinyA
即使用户未登录并尝试打开主页,在被重定向到登录页面后,也会显示 authError。是否有一种优雅的方法来防止这种情况,而无需修改 Auth 组件?这是我加载 Auth 组件的方式(我使用 TinyA
我是一名优秀的程序员,十分优秀!