On a project I am currently working on I have three roles: Admin, Super-user and User.
Admins can delete users, delete comments etc, but Super-users must be able to delete comments too. So I built an AdminController
and Authorized it with Admin. One method must be accessable with the Super-user, so I authorized it for the Super-user but that won't work.
[Authorize(Roles = "Admin")]
public class AdminController : Controller
{
(... here be only admin methods ...)
[HttpGet]
[Authorize(Roles = "Super-user")]
public ActionResult Delete()
{
//deletes a comment
return View();
}
(... here be only admin methods ...)
}
I looked into overriding the Authorize
attribute but I'm trying to find a solution where that is not needed, any idea's on how to authorize just one method for the Super-user?
The Admin as the Super-user must have access to the method Delete()
.
Thanks!