Created
November 4, 2014 20:41
-
-
Save ithielnor/9a0cf811b2a7bf88ecfe 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
var actionLevelAttributes = actionDescriptor.GetFilterAttributes(true); | |
var controllerLevelAttributes = controllerType.GetCustomAttributes(true); | |
var assocAttribute = actionLevelAttributes.OfType<AssociationAttribute>().Union(controllerLevelAttributes.OfType<AssociationAttribute>()).FirstOrDefault(); | |
var moduleAttribute = actionLevelAttributes.OfType<ModuleAttribute>().Union(controllerLevelAttributes.OfType<ModuleAttribute>()).FirstOrDefault(); | |
var permissionAttribute = actionLevelAttributes.OfType<RequiresPermissionAttribute>().Union(controllerLevelAttributes.OfType<RequiresPermissionAttribute>()).FirstOrDefault(); | |
if ((assocAttribute != null && !assocAttribute.Authorized()) | |
|| (moduleAttribute != null && !moduleAttribute.Authorized()) | |
|| (permissionAttribute != null && !permissionAttribute.Authorized())) | |
return false; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment