简体   繁体   English

CakePHP ACL和Auth无法正常工作

[英]CakePHP ACL and Auth not working

I have a few questions about CakePHPs ACL and Auth system. 我有几个关于CakePHPs ACL和Auth系统的问题。

  1. Whats the naming convention of the aliases in the acos table? 什么是acos表中别名的命名约定? Is it 'controllers/Posts/add' or just 'add' with the parent id from 'Posts'? 是'控制器/帖子/添加'还是只是'添加'来自'帖子'的父ID?
  2. My login doesn't work. 我的登录不起作用。 When I try to login I don't get any error message but the Auth.User and the Auth->user('id') are both empty. 当我尝试登录时,我没有收到任何错误消息,但Auth.User和Auth-> user('id')都是空的。 What could be the problem? 可能是什么问题呢? I do everything like in the ACL example from CakePHP. 我在CakePHP的ACL示例中做了所有事情。

Thank you. 谢谢。

UPDATE: My login works now (Problem with the time settings on the server) and my acos table looks right but I can't go to any action. 更新:我的登录现在工作(服务器上的时间设置问题)和我的acos表看起来正确,但我不能采取任何行动。 I allowed the action in the aros_acos table. 我允许在aros_acos表中执行操作。 If I check the permission with '$this->Acl->check()' it just works if I give the single name of the action and not the full path ('controllers/Posts/add' doesn't work). 如果我使用'$ this-> Acl-> check()'检查权限,如果我给出操作的单个名称而不是完整路径('controllers / Posts / add'不起作用),它就可以工作。

I solved the problems by: 我解决了以下问题:

  1. Make sure the time on the server is correct. 确保服务器上的时间正确。 Otherwise sessions won't work. 否则会话将无效。
  2. Correct the table data in the acos table. 更正acos表中的表数据。 Especially make sure that the 'lft' and 'rght' values are correct. 特别要确保'lft'和'rght'值是正确的。 This page may helps: http://www.sitepoint.com/hierarchical-data-database-2/ 此页面可能有所帮助: http//www.sitepoint.com/hierarchical-data-database-2/
  3. You need to add every action you want to use to the acos table. 您需要将要使用的每个操作添加到acos表中。 If you don't do this you're not allowed to do this action. 如果您不这样做,则不允许您执行此操作。 Even if you allow the hole controller. 即使你允许孔控制器。

To fill the ACO datatable easily, you could also use my plugin: http://www.alaxos.net/blaxos/pages/view/plugin_acl_2.0 要轻松填充ACO数据表,您还可以使用我的插件: http//www.alaxos.net/blaxos/pages/view/plugin_acl_2.0

Then no need to bother how the records have to be created, it would do it for you ;-) 然后无需打扰如何创建记录,它会为你做;-)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM