阻止从用户 ID 访问用户个人资料页面
我有一个用户个人资料页面,其网址如下: www.XXXXXXX.com/userid/45
当用户将 /userid/45 更改为 /userid/47 时,有没有办法阻止访问其他页面
i have a user profile page that have the following url : www.XXXXXXX.com/userid/45
is there a way to prevent access to other page when a user change /userid/45 to /userid/47
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
根据您使用的语言,用户个人资料页面上会显示如下内容:
Depending on the language you're using, something like this on the user profile page:
您可能想看一下 Zend_Acl。
http://framework.zend.com/manual/en/zend.acl .introduction.html
这将允许您根据发出请求的角色分配的权限来控制对某些资源(例如配置文件)的访问。您还可以使用断言指定更细粒度的访问。
因此,举例来说,您为在您的网站上注册的用户指定了一个“注册”角色,这些用户也将拥有一个个人资料页面。您的规则可能如下所示:-
“已注册”可以“显示”“个人资料”“如果这是他们的个人资料”。
角色:“注册”
权限:“显示”
资源:“个人资料”
断言:检查所有权的代码
You might want to take a look at Zend_Acl.
http://framework.zend.com/manual/en/zend.acl.introduction.html
This would allow you to control access to certain resources (e.g. a profile) based upon the assigned privileges of the role making the request. You can also specify more fine-grained access with assertions.
So, say for example, you specified an 'registered' role, for users registered with your site, who would also have a profile page. Your rule might read like this :-
'registered' can 'display' a 'profile' 'if it is their profile'.
Role: 'registered'
Privilege: 'display'
Resource: 'profile'
Assertion: code that checks for ownership
我一直在 WordPress 中寻找这个,只有在发布我的答案后,我才意识到你在问 WordPress 以外的东西......哦,好吧,对于犯我同样错误的人来说,这是同样的事情,但对于 WordPress:
你可以修改此设置,通过将
==
更改为!=
并仅输入管理员 ID(通常为“1”),使其重定向所有用户,而不仅仅是一个用户。I was looking for this in wordpress and only after posting my answer did I even realize you were asking about something other than wordpress... Oh well, for people who make my same mistake, here is the same thing, but for wordpress:
You can modify this to make it redirect all users instead of just one user by changing the
==
to!=
and enter just the admin id (usually "1").