如何限制数据给拥有它的用户,而不限制管理员用户在CakePHP? [英] How to limit data to users who own it without limiting admin users in CakePHP?

查看:125
本文介绍了如何限制数据给拥有它的用户,而不限制管理员用户在CakePHP?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前我正在写一个应用程序,其中有多个用户。它们具有应该只对他们可见的数据,而不是系统中的其他已验证用户。我也有管理员管理系统和访问所有的信息。什么是限制用户访问其数据而不限制管理用户的最佳方法?

Currently I am writing an application where I have multiple users. They have data that should only be visible to them and not the other authenticated users in the system. I also have administrators who manage the system and have access to all of the information. What is the best way to limit users to their data without limiting admin users?

目前我使用回调来限制用户的查询,但管理员将获得相同的限制。所以我需要知道一个更好的方法来做到这一点。更重要的是,正确的方法。

Currently I am using a callback to limit the queries by user, but the admin will get the same limits. So I need to know a better way to do it. More importantly, the right way to do it.

例如,我想标准用户只能看到他们的用户信息,仅供参考。然而,管理员应该能够看到所有用户和CRUD所有用户数据。任何想法?

For example, I want the standard user to be able to see their user information only and be limited to CRUD operations on their information only. The admin, however, should be able to see ALL users and CRUD ALL user data. Any ideas?

推荐答案

没有找到我在互联网上寻找,由于我无法沟通我正在寻找),我花了最近几天写一个解决方案。我终于有我想要的解决方案。虽然这里的一些答案是写在轨道上,他们只是不够完整,我正在寻找。

After not finding what I was looking for on the Internet, and not getting a solution posted here (most likely due to my inability to communicate what I was looking for), I spent the last few days writing a solution. I finally have the solution I am looking for. While some of the answers here were on the write track, they just were not complete enough for what I was looking for.

由于没有足够的空间,这里张贴结果,我将内容添加到我的博客。您可以在此处 blogchuck.com 准备好。

Since there is not enough room here to post the results, I added the content to my blog. You can ready it here at blogchuck.com. Please feel free to blast it to pieces, it will help us all in the long run.

感谢所有花时间张贴的人。

Thanks to everyone who took the time to post.

这篇关于如何限制数据给拥有它的用户,而不限制管理员用户在CakePHP?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆