Created
April 19, 2012 18:48
-
-
Save cbcwebdev/2422946 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 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