Simplify AuthenticationHandler using LINQ

This commit is contained in:
Hisham Bin Ateya 2015-10-26 02:44:48 +03:00 committed by Chris R
parent f8ff2cd6d1
commit 29b90ea070
1 changed files with 8 additions and 10 deletions

View File

@ -35,8 +35,8 @@ namespace Microsoft.AspNet.IISPlatformHandler
if (User != null) if (User != null)
{ {
context.Authenticated(User, properties: null, context.Authenticated(User, properties: null,
description: Options.AuthenticationDescriptions.Where(descrip => description: Options.AuthenticationDescriptions.FirstOrDefault(descrip =>
string.Equals(User.Identity.AuthenticationType, descrip.AuthenticationScheme, StringComparison.Ordinal)).FirstOrDefault()?.Items); string.Equals(User.Identity.AuthenticationType, descrip.AuthenticationScheme, StringComparison.Ordinal))?.Items);
} }
else else
{ {
@ -48,6 +48,7 @@ namespace Microsoft.AspNet.IISPlatformHandler
{ {
return PriorHandler.AuthenticateAsync(context); return PriorHandler.AuthenticateAsync(context);
} }
return Task.FromResult(0); return Task.FromResult(0);
} }
@ -84,6 +85,7 @@ namespace Microsoft.AspNet.IISPlatformHandler
{ {
return PriorHandler.ChallengeAsync(context); return PriorHandler.ChallengeAsync(context);
} }
return Task.FromResult(0); return Task.FromResult(0);
} }
@ -107,6 +109,7 @@ namespace Microsoft.AspNet.IISPlatformHandler
{ {
return PriorHandler.SignInAsync(context); return PriorHandler.SignInAsync(context);
} }
return Task.FromResult(0); return Task.FromResult(0);
} }
@ -117,6 +120,7 @@ namespace Microsoft.AspNet.IISPlatformHandler
{ {
return PriorHandler.SignOutAsync(context); return PriorHandler.SignOutAsync(context);
} }
return Task.FromResult(0); return Task.FromResult(0);
} }
@ -126,14 +130,8 @@ namespace Microsoft.AspNet.IISPlatformHandler
{ {
return true; return true;
} }
foreach (var description in Options.AuthenticationDescriptions)
{ return Options.AuthenticationDescriptions.Any(description => string.Equals(description.AuthenticationScheme, authenticationScheme, StringComparison.Ordinal));
if (string.Equals(description.AuthenticationScheme, authenticationScheme, StringComparison.Ordinal))
{
return true;
}
}
return false;
} }
} }
} }