Skip to content

Instantly share code, notes, and snippets.

@OdeToCode
Created September 21, 2012 19:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save OdeToCode/3763562 to your computer and use it in GitHub Desktop.
Save OdeToCode/3763562 to your computer and use it in GitHub Desktop.
public class OwershipVerification : IActionFilter
{
public void OnActionExecuting(ActionExecutingContext filterContext)
{
foreach(var paramter in filterContext.ActionParameters)
{
var haveAnOwner = paramter.Value as IHaveAnOwner;
if(haveAnOwner != null)
{
var ownedParameter = haveAnOwner;
if(ownedParameter.OwnerId != WebSecurity.CurrentUserId)
{
// ... do whatever
}
}
}
}
public void OnActionExecuted(ActionExecutedContext filterContext)
{
}
}
public interface IHaveAnOwner
{
int OwnerId { get; set; }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment