我正在尝试在自定义模块的 Web API 方法上使用此属性:
[DnnModuleAuthorize(AccessLevel = DotNetNuke.Security.SecurityAccessLevel.Edit)]
但无论我设置什么 SecurityAccessLevel,我总是得到 401 未经授权的响应。
我能够通过添加使代码工作:
[AllowAnonymous]
在方法上,并添加:
if (!ModulePermissionController.CanEditModuleContent(this.ActiveModule))
return Request.CreateErrorResponse(HttpStatusCode.Unauthorized, "You do not have permission to access this content.");
到我的方法的开头,但似乎这是我真的不需要的解决方法,因为它正是该属性的用途。我正在运行 DNN 7.2.1。
有人知道我的属性在哪里出错了吗?