0

我正在尝试保护 NOPCommerce 2.8 网站的论坛(板)文件夹。我想使用现有的会员提供者和附带的角色。我只希望角色组“论坛版主”能够查看论坛中的内容,如果他们点击论坛,任何其他角色组或匿名用户将被重定向到登录页面。

这对于 .aspx 页面来说很容易,我会说“,这会阻止匿名用户访问,但对于 .cshtml 页面,它不起作用。

有没有人有一个简单的解决方案来使用 nopcommerce 的现有角色安全性来保护论坛?

谢谢

4

2 回答 2

0

如果您了解 ActionFilters,您可以通过插件轻松实现结果。您需要做的就是检查 ActionFilters 的“OnActionExecuting”方法中的角色。如果您在 nopCommerce.com 论坛上搜索,我还写了一些帖子来解释这一点。:)

于 2013-01-18T16:18:02.920 回答
0

这是我在 Nopcommerce 论坛中的某人的帮助下保护论坛的方法

@using Nop.Core.Domain.Customers;
@using Nop.Services.Customers;
@using Nop.Core;
@{
bool customerHasRoleX = EngineContext.Current.Resolve<IWorkContext>().CurrentCustomer.IsInCustomerRole("Administrators");
bool customerHasRoleY = EngineContext.Current.Resolve<IWorkContext>().CurrentCustomer.IsInCustomerRole("ForumModerators");
}

@if ((customerHasRoleX == true) | (customerHasRoleY == true)) {

}
else
{
    Response.Redirect("~/login?ReturnUrl=%2fboards");
}
于 2013-01-31T16:09:56.987 回答