Created
September 21, 2012 19:59
-
-
Save OdeToCode/3763562 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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