Remove allow anonymous (will happen as a separate feature)

This commit is contained in:
Yishai Galatzer 2014-03-06 17:06:21 -08:00
parent 5503aa7b4a
commit bcfccbd105
2 changed files with 2 additions and 14 deletions

View File

@ -19,7 +19,5 @@ namespace Microsoft.AspNet.Mvc
public List<ParameterDescriptor> Parameters { get; set; } public List<ParameterDescriptor> Parameters { get; set; }
public List<IFilter> Filters { get; set; } public List<IFilter> Filters { get; set; }
public bool AllowAnonymous { get; set; }
} }
} }

View File

@ -46,8 +46,6 @@ namespace Microsoft.AspNet.Mvc
var controllerAttributes = cd.ControllerTypeInfo.GetCustomAttributes(inherit: true).ToArray(); var controllerAttributes = cd.ControllerTypeInfo.GetCustomAttributes(inherit: true).ToArray();
var filtersFromController = GetOrderedFilterAttributes(controllerAttributes); var filtersFromController = GetOrderedFilterAttributes(controllerAttributes);
bool allowAnonymous = IsAnonymous(controllerAttributes);
foreach (var methodInfo in cd.ControllerTypeInfo.DeclaredMethods) foreach (var methodInfo in cd.ControllerTypeInfo.DeclaredMethods)
{ {
var actionInfos = _conventions.GetActions(methodInfo); var actionInfos = _conventions.GetActions(methodInfo);
@ -59,17 +57,12 @@ namespace Microsoft.AspNet.Mvc
foreach (var actionInfo in actionInfos) foreach (var actionInfo in actionInfos)
{ {
yield return BuildDescriptor(cd, methodInfo, actionInfo, filtersFromController, allowAnonymous); yield return BuildDescriptor(cd, methodInfo, actionInfo, filtersFromController);
} }
} }
} }
} }
private bool IsAnonymous(object[] attributes)
{
return attributes.OfType<AllowAnonymousAttribute>().Any();
}
private IFilter[] GetOrderedFilterAttributes(object[] attributes) private IFilter[] GetOrderedFilterAttributes(object[] attributes)
{ {
var filters = attributes.OfType<IFilter>().OrderByDescending(filter => filter.Order); var filters = attributes.OfType<IFilter>().OrderByDescending(filter => filter.Order);
@ -80,8 +73,7 @@ namespace Microsoft.AspNet.Mvc
private ReflectedActionDescriptor BuildDescriptor(ControllerDescriptor controllerDescriptor, private ReflectedActionDescriptor BuildDescriptor(ControllerDescriptor controllerDescriptor,
MethodInfo methodInfo, MethodInfo methodInfo,
ActionInfo actionInfo, ActionInfo actionInfo,
IFilter[] controllerFilters, IFilter[] controllerFilters)
bool allowAnonymous)
{ {
var ad = new ReflectedActionDescriptor var ad = new ReflectedActionDescriptor
{ {
@ -122,8 +114,6 @@ namespace Microsoft.AspNet.Mvc
ad.Filters = MergeSorted(filtersFromAction, controllerFilters); ad.Filters = MergeSorted(filtersFromAction, controllerFilters);
ad.AllowAnonymous = allowAnonymous || IsAnonymous(attributes);
return ad; return ad;
} }