用户关系和用户访问控制
用户关系可以很好地控制节点对每个批准的用户列表的内容的访问。
但我遇到的问题是,我还想使用核心配置文件模块,并允许通过用户关系连接的用户查看彼此的用户配置文件。我花了 2 个小时试图找到一种方法,不允许用户欺骗 URL 并查看任何用户帐户(当前需要访问用户配置文件权限才能查看用户配置文件)。
我想了几个解决方案来解决这个问题。我想要做的是,如果 URL 被欺骗并且请求用户无权访问,则提供 403 页面。
这就是我的想法:
- 禁用访问用户配置文件权限
- 在自定义模块中调用 hook_menu_alter 或 hook_menu_link_alter
- 将访问回调更改为自定义函数,检查用户关系
- 如果不存在关系,则提供 403,否则返回 user_view
我想了解一些想法这是因为我希望在用户个人资料页面上进行此检查。 hook_init() 看起来太强大了。
这会是一个有效的解决方案吗?想法?或者是否有一个模块可以让我快速完成此操作?
User Relationships works well to control node access to content per an approved user list.
But the problem I am running into is that I would like to also use the core Profile module, and allow those who are connected via User Relationships to see each others user profiles. I have spent 2 hours trying to figure out a way to not allow a user to spoof the URL and see any user account (Access User Profiles permission is required to see user profiles currently).
I thought of a couple solutions to fix this. What I want to do is serve a 403 page if the URL is spoofed and the requesting user has no access.
Here is what I was thinking:
- Disable Access User Profile permission
- Call hook_menu_alter or hook_menu_link_alter in a custom module
- Change access callback to a custom function, check for user relationship
- If no relationship exists serve a 403, otherwise return user_view
I wanted to get some thoughts on this, because I want this check to happen on the user profile page. hook_init() seemed too beefy.
Would this be an effective solution? Thoughts? Or is there a module that will allow me to do this quickly?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要的一切:CCK 私有字段 + 内容简介
All you need: CCK Private Fields + Content Profile