add ModuleControllerBase helper method for validating EntityId
This commit is contained in:
@ -29,7 +29,7 @@ namespace Oqtane.Modules.HtmlText.Controllers
|
||||
[Authorize(Roles = RoleNames.Registered)]
|
||||
public IEnumerable<Models.HtmlText> Get(string moduleId)
|
||||
{
|
||||
if (int.TryParse(moduleId, out int ModuleId) && AuthEntityId(EntityNames.Module) == ModuleId)
|
||||
if (int.TryParse(moduleId, out int ModuleId) && IsAuthorizedEntityId(EntityNames.Module, ModuleId))
|
||||
{
|
||||
return _htmlText.GetHtmlTexts(ModuleId);
|
||||
}
|
||||
@ -46,7 +46,7 @@ namespace Oqtane.Modules.HtmlText.Controllers
|
||||
[Authorize(Policy = PolicyNames.ViewModule)]
|
||||
public Models.HtmlText Get(int moduleId)
|
||||
{
|
||||
if (AuthEntityId(EntityNames.Module) == moduleId)
|
||||
if (IsAuthorizedEntityId(EntityNames.Module, moduleId))
|
||||
{
|
||||
var htmltexts = _htmlText.GetHtmlTexts(moduleId);
|
||||
if (htmltexts != null && htmltexts.Any())
|
||||
@ -71,7 +71,7 @@ namespace Oqtane.Modules.HtmlText.Controllers
|
||||
[Authorize(Policy = PolicyNames.ViewModule)]
|
||||
public Models.HtmlText Get(int id, int moduleId)
|
||||
{
|
||||
if (AuthEntityId(EntityNames.Module) == moduleId)
|
||||
if (IsAuthorizedEntityId(EntityNames.Module, moduleId))
|
||||
{
|
||||
return _htmlText.GetHtmlText(id);
|
||||
}
|
||||
@ -88,7 +88,7 @@ namespace Oqtane.Modules.HtmlText.Controllers
|
||||
[Authorize(Policy = PolicyNames.EditModule)]
|
||||
public Models.HtmlText Post([FromBody] Models.HtmlText htmlText)
|
||||
{
|
||||
if (ModelState.IsValid && AuthEntityId(EntityNames.Module) == htmlText.ModuleId)
|
||||
if (ModelState.IsValid && IsAuthorizedEntityId(EntityNames.Module, htmlText.ModuleId))
|
||||
{
|
||||
htmlText = _htmlText.AddHtmlText(htmlText);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Create, "Html/Text Added {HtmlText}", htmlText);
|
||||
@ -107,7 +107,7 @@ namespace Oqtane.Modules.HtmlText.Controllers
|
||||
[Authorize(Policy = PolicyNames.EditModule)]
|
||||
public void Delete(int id, int moduleId)
|
||||
{
|
||||
if (AuthEntityId(EntityNames.Module) == moduleId)
|
||||
if (IsAuthorizedEntityId(EntityNames.Module, moduleId))
|
||||
{
|
||||
_htmlText.DeleteHtmlText(id);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Delete, "Html/Text Deleted {HtmlTextId}", id);
|
||||
|
Reference in New Issue
Block a user