Skip to content

Instantly share code, notes, and snippets.

@cbcwebdev
Created April 19, 2012 18:48
Show Gist options
  • Save cbcwebdev/2422946 to your computer and use it in GitHub Desktop.
Save cbcwebdev/2422946 to your computer and use it in GitHub Desktop.
public class IHandleRequestsForRoles : ActionSelectorMethodAttribute
{
public string Roles { get; set; }
public override bool IsValidForRequest(ControllerContext controllerContext, MethodInfo methodInfo)
{
var roles = Roles.GetRolesForUser();
var segments = this.Roles.Split(',');
bool isValidForRequest = false;
foreach(var segment in segments)
{
if(roles.Contains(segment))
{
isValidForRequest = true;
break;
}
}
return isValidForRequest;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment