ユーザーがアクセス権のないエンティティにアクセスできないように、コントローラー アクションを保護しようとしています。次のコードでこれを行うことができます。
public ActionResult Entity(string entityCode)
{
if (CurrentUser.VerifyEntityPermission(entityCode))
{
//populate viewModel...
return View(viewModel);
}
return RedirectToAction("NoAccessToEntity", "Error");
}
コントローラー アクション自体に属性を追加できるようにしたいと考えています。エンティティへのアクセスを検証するには、コントローラーに渡された値と、ユーザーがアクセスできるエンティティを確認する必要があります。これは可能ですか?
[EntityAuthRequired]
public ActionResult Entity(string entityCode)
{
//populate viewModel...
return View(viewModel);
}