diff --git a/src/Microsoft.AspNet.Identity/ClaimsIdentityFactory.cs b/src/Microsoft.AspNet.Identity/ClaimsIdentityFactory.cs
index bda8839ac8..8e079d6e3b 100644
--- a/src/Microsoft.AspNet.Identity/ClaimsIdentityFactory.cs
+++ b/src/Microsoft.AspNet.Identity/ClaimsIdentityFactory.cs
@@ -77,16 +77,14 @@ namespace Microsoft.AspNet.Identity
/// The user instance to create claims on.
/// A to observe while waiting for the tasks to complete.
/// A that represents the started task.
- public virtual async Task CreateAsync(
- TUser user,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task CreateAsync(TUser user)
{
if (user == null)
{
throw new ArgumentNullException("user");
}
- var userId = await UserManager.GetUserIdAsync(user, cancellationToken);
- var userName = await UserManager.GetUserNameAsync(user, cancellationToken);
+ var userId = await UserManager.GetUserIdAsync(user);
+ var userName = await UserManager.GetUserNameAsync(user);
var id = new ClaimsIdentity(IdentityOptions.ApplicationCookieAuthenticationType, Options.ClaimsIdentity.UserNameClaimType,
Options.ClaimsIdentity.RoleClaimType);
id.AddClaim(new Claim(Options.ClaimsIdentity.UserIdClaimType, userId));
@@ -94,11 +92,11 @@ namespace Microsoft.AspNet.Identity
if (UserManager.SupportsUserSecurityStamp)
{
id.AddClaim(new Claim(Options.ClaimsIdentity.SecurityStampClaimType,
- await UserManager.GetSecurityStampAsync(user, cancellationToken)));
+ await UserManager.GetSecurityStampAsync(user)));
}
if (UserManager.SupportsUserRole)
{
- var roles = await UserManager.GetRolesAsync(user, cancellationToken);
+ var roles = await UserManager.GetRolesAsync(user);
foreach (var roleName in roles)
{
id.AddClaim(new Claim(Options.ClaimsIdentity.RoleClaimType, roleName, ClaimValueTypes.String));
@@ -107,14 +105,14 @@ namespace Microsoft.AspNet.Identity
var role = await RoleManager.FindByNameAsync(roleName);
if (role != null)
{
- id.AddClaims(await RoleManager.GetClaimsAsync(role, cancellationToken));
+ id.AddClaims(await RoleManager.GetClaimsAsync(role));
}
}
}
}
if (UserManager.SupportsUserClaim)
{
- id.AddClaims(await UserManager.GetClaimsAsync(user, cancellationToken));
+ id.AddClaims(await UserManager.GetClaimsAsync(user));
}
return id;
}
diff --git a/src/Microsoft.AspNet.Identity/DataProtectionTokenProvider.cs b/src/Microsoft.AspNet.Identity/DataProtectionTokenProvider.cs
index ebe628175e..2d3e3bf66a 100644
--- a/src/Microsoft.AspNet.Identity/DataProtectionTokenProvider.cs
+++ b/src/Microsoft.AspNet.Identity/DataProtectionTokenProvider.cs
@@ -65,15 +65,14 @@ namespace Microsoft.AspNet.Identity
/// The the token will be generated from.
/// A to observe while waiting for the tasks to complete.
/// A that contains the protected token.
- public virtual async Task GenerateAsync(string purpose, UserManager manager, TUser user,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task GenerateAsync(string purpose, UserManager manager, TUser user)
{
if (user == null)
{
throw new ArgumentNullException("user");
}
var ms = new MemoryStream();
- var userId = await manager.GetUserIdAsync(user, cancellationToken);
+ var userId = await manager.GetUserIdAsync(user);
using (var writer = ms.CreateWriter())
{
writer.Write(DateTimeOffset.UtcNow);
@@ -97,10 +96,8 @@ namespace Microsoft.AspNet.Identity
/// The token to validate.
/// The to retrieve user properties from.
/// The the token was generated for.
- /// A to observe while waiting for the tasks to complete.
/// A that is true if the token is valid, otherwise false.
- public virtual async Task ValidateAsync(string purpose, string token, UserManager manager, TUser user,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task ValidateAsync(string purpose, string token, UserManager manager, TUser user)
{
try
{
@@ -116,7 +113,7 @@ namespace Microsoft.AspNet.Identity
}
var userId = reader.ReadString();
- var actualUserId = await manager.GetUserIdAsync(user, cancellationToken);
+ var actualUserId = await manager.GetUserIdAsync(user);
if (userId != actualUserId)
{
return false;
@@ -155,8 +152,7 @@ namespace Microsoft.AspNet.Identity
/// The the token was generated for.
/// True if a token generated by this instance can be used as a Two Factor Authentication token, otherwise false.
/// This method will always return false for instances of .
- public virtual Task CanGenerateTwoFactorTokenAsync(UserManager manager, TUser user,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual Task CanGenerateTwoFactorTokenAsync(UserManager manager, TUser user)
{
return Task.FromResult(false);
}
@@ -167,10 +163,8 @@ namespace Microsoft.AspNet.Identity
/// The token to generate notifications for..
/// The to retrieve user properties from.
/// The the token was generated for.
- /// A to observe while waiting for the tasks to complete.
/// A that represents the started task.
- public virtual Task NotifyAsync(string token, UserManager manager, TUser user,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual Task NotifyAsync(string token, UserManager manager, TUser user)
{
return Task.FromResult(0);
}
diff --git a/src/Microsoft.AspNet.Identity/EmailTokenProvider.cs b/src/Microsoft.AspNet.Identity/EmailTokenProvider.cs
index 6f80f9fbc0..d192dde38e 100644
--- a/src/Microsoft.AspNet.Identity/EmailTokenProvider.cs
+++ b/src/Microsoft.AspNet.Identity/EmailTokenProvider.cs
@@ -46,11 +46,10 @@ namespace Microsoft.AspNet.Identity
///
///
///
- public override async Task CanGenerateTwoFactorTokenAsync(UserManager manager, TUser user,
- CancellationToken cancellationToken = default(CancellationToken))
+ public override async Task CanGenerateTwoFactorTokenAsync(UserManager manager, TUser user)
{
- var email = await manager.GetEmailAsync(user, cancellationToken);
- return !string.IsNullOrWhiteSpace(email) && await manager.IsEmailConfirmedAsync(user, cancellationToken);
+ var email = await manager.GetEmailAsync(user);
+ return !string.IsNullOrWhiteSpace(email) && await manager.IsEmailConfirmedAsync(user);
}
///
@@ -61,9 +60,9 @@ namespace Microsoft.AspNet.Identity
///
///
public override async Task GetUserModifierAsync(string purpose, UserManager manager,
- TUser user, CancellationToken cancellationToken = default(CancellationToken))
+ TUser user)
{
- var email = await manager.GetEmailAsync(user, cancellationToken);
+ var email = await manager.GetEmailAsync(user);
return "Email:" + purpose + ":" + email;
}
@@ -74,8 +73,7 @@ namespace Microsoft.AspNet.Identity
///
///
///
- public override async Task NotifyAsync(string token, UserManager manager, TUser user,
- CancellationToken cancellationToken = default(CancellationToken))
+ public override async Task NotifyAsync(string token, UserManager manager, TUser user)
{
if (manager == null)
{
@@ -83,11 +81,11 @@ namespace Microsoft.AspNet.Identity
}
var msg = new IdentityMessage
{
- Destination = await manager.GetEmailAsync(user, cancellationToken),
+ Destination = await manager.GetEmailAsync(user),
Subject = Options.Subject,
Body = string.Format(CultureInfo.CurrentCulture, Options.BodyFormat, token)
};
- await manager.SendMessageAsync(Options.MessageProvider, msg, cancellationToken);
+ await manager.SendMessageAsync(Options.MessageProvider, msg);
}
}
}
\ No newline at end of file
diff --git a/src/Microsoft.AspNet.Identity/IClaimsIdentityFactory.cs b/src/Microsoft.AspNet.Identity/IClaimsIdentityFactory.cs
index a59826a713..ac1c950bb6 100644
--- a/src/Microsoft.AspNet.Identity/IClaimsIdentityFactory.cs
+++ b/src/Microsoft.AspNet.Identity/IClaimsIdentityFactory.cs
@@ -19,8 +19,7 @@ namespace Microsoft.AspNet.Identity
///
///
///
- ///
///
- Task CreateAsync(TUser user, CancellationToken cancellationToken = default(CancellationToken));
+ Task CreateAsync(TUser user);
}
}
\ No newline at end of file
diff --git a/src/Microsoft.AspNet.Identity/IIdentityMessageProvider.cs b/src/Microsoft.AspNet.Identity/IIdentityMessageProvider.cs
index 0c0ea30bbd..2eaa60a115 100644
--- a/src/Microsoft.AspNet.Identity/IIdentityMessageProvider.cs
+++ b/src/Microsoft.AspNet.Identity/IIdentityMessageProvider.cs
@@ -10,6 +10,6 @@ namespace Microsoft.AspNet.Identity
{
string Name { get; }
- Task SendAsync(IdentityMessage message, CancellationToken cancellationToken = default(CancellationToken));
+ Task SendAsync(IdentityMessage message, CancellationToken cancellationToken);
}
}
\ No newline at end of file
diff --git a/src/Microsoft.AspNet.Identity/IPasswordValidator.cs b/src/Microsoft.AspNet.Identity/IPasswordValidator.cs
index d851d324fb..54ba27d781 100644
--- a/src/Microsoft.AspNet.Identity/IPasswordValidator.cs
+++ b/src/Microsoft.AspNet.Identity/IPasswordValidator.cs
@@ -15,7 +15,6 @@ namespace Microsoft.AspNet.Identity
/// Validate the password for the user
///
///
- Task ValidateAsync(UserManager manager, TUser user, string password,
- CancellationToken cancellationToken = default(CancellationToken));
+ Task ValidateAsync(UserManager manager, TUser user, string password);
}
}
\ No newline at end of file
diff --git a/src/Microsoft.AspNet.Identity/IRoleStore.cs b/src/Microsoft.AspNet.Identity/IRoleStore.cs
index 405a47ce31..c9f33b18a3 100644
--- a/src/Microsoft.AspNet.Identity/IRoleStore.cs
+++ b/src/Microsoft.AspNet.Identity/IRoleStore.cs
@@ -19,7 +19,7 @@ namespace Microsoft.AspNet.Identity
///
///
///
- Task CreateAsync(TRole role, CancellationToken cancellationToken = default(CancellationToken));
+ Task CreateAsync(TRole role, CancellationToken cancellationToken);
///
/// Update a role
@@ -27,7 +27,7 @@ namespace Microsoft.AspNet.Identity
///
///
///
- Task UpdateAsync(TRole role, CancellationToken cancellationToken = default(CancellationToken));
+ Task UpdateAsync(TRole role, CancellationToken cancellationToken);
///
/// DeleteAsync a role
@@ -35,7 +35,7 @@ namespace Microsoft.AspNet.Identity
///
///
///
- Task DeleteAsync(TRole role, CancellationToken cancellationToken = default(CancellationToken));
+ Task DeleteAsync(TRole role, CancellationToken cancellationToken);
///
/// Returns a role's id
@@ -43,7 +43,7 @@ namespace Microsoft.AspNet.Identity
///
///
///
- Task GetRoleIdAsync(TRole role, CancellationToken cancellationToken = default(CancellationToken));
+ Task GetRoleIdAsync(TRole role, CancellationToken cancellationToken);
///
/// Returns a role's name
@@ -51,7 +51,7 @@ namespace Microsoft.AspNet.Identity
///
///
///
- Task GetRoleNameAsync(TRole role, CancellationToken cancellationToken = default(CancellationToken));
+ Task GetRoleNameAsync(TRole role, CancellationToken cancellationToken);
///
/// Set a role's name
@@ -60,8 +60,7 @@ namespace Microsoft.AspNet.Identity
///
///
///
- Task SetRoleNameAsync(TRole role, string roleName,
- CancellationToken cancellationToken = default(CancellationToken));
+ Task SetRoleNameAsync(TRole role, string roleName, CancellationToken cancellationToken);
///
/// Get a role's normalized name
@@ -69,8 +68,7 @@ namespace Microsoft.AspNet.Identity
///
///
///
- Task GetNormalizedRoleNameAsync(TRole role,
- CancellationToken cancellationToken = default(CancellationToken));
+ Task GetNormalizedRoleNameAsync(TRole role, CancellationToken cancellationToken);
///
/// Set a role's normalized name
@@ -79,8 +77,7 @@ namespace Microsoft.AspNet.Identity
///
///
///
- Task SetNormalizedRoleNameAsync(TRole role, string normalizedName,
- CancellationToken cancellationToken = default(CancellationToken));
+ Task SetNormalizedRoleNameAsync(TRole role, string normalizedName, CancellationToken cancellationToken);
///
@@ -89,7 +86,7 @@ namespace Microsoft.AspNet.Identity
///
///
///
- Task FindByIdAsync(string roleId, CancellationToken cancellationToken = default(CancellationToken));
+ Task FindByIdAsync(string roleId, CancellationToken cancellationToken);
///
/// Find a role by normalized name
@@ -97,6 +94,6 @@ namespace Microsoft.AspNet.Identity
///
///
///
- Task FindByNameAsync(string normalizedRoleName, CancellationToken cancellationToken = default(CancellationToken));
+ Task FindByNameAsync(string normalizedRoleName, CancellationToken cancellationToken);
}
}
\ No newline at end of file
diff --git a/src/Microsoft.AspNet.Identity/IRoleValidator.cs b/src/Microsoft.AspNet.Identity/IRoleValidator.cs
index 7057c69e69..823652dd0e 100644
--- a/src/Microsoft.AspNet.Identity/IRoleValidator.cs
+++ b/src/Microsoft.AspNet.Identity/IRoleValidator.cs
@@ -17,9 +17,7 @@ namespace Microsoft.AspNet.Identity
///
///
///
- ///
///
- Task ValidateAsync(RoleManager manager, TRole role,
- CancellationToken cancellationToken = default(CancellationToken));
+ Task ValidateAsync(RoleManager manager, TRole role);
}
}
\ No newline at end of file
diff --git a/src/Microsoft.AspNet.Identity/ISecurityStampValidator.cs b/src/Microsoft.AspNet.Identity/ISecurityStampValidator.cs
index f50a163e46..7f6b915482 100644
--- a/src/Microsoft.AspNet.Identity/ISecurityStampValidator.cs
+++ b/src/Microsoft.AspNet.Identity/ISecurityStampValidator.cs
@@ -2,7 +2,6 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Security.Claims;
-using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNet.Security.Cookies;
@@ -10,7 +9,6 @@ namespace Microsoft.AspNet.Identity
{
public interface ISecurityStampValidator
{
- Task ValidateAsync(CookieValidateIdentityContext context, ClaimsIdentity identity,
- CancellationToken cancellationToken = default(CancellationToken));
+ Task ValidateAsync(CookieValidateIdentityContext context, ClaimsIdentity identity);
}
}
\ No newline at end of file
diff --git a/src/Microsoft.AspNet.Identity/IUserClaimStore.cs b/src/Microsoft.AspNet.Identity/IUserClaimStore.cs
index 825c289b0e..4e977c249e 100644
--- a/src/Microsoft.AspNet.Identity/IUserClaimStore.cs
+++ b/src/Microsoft.AspNet.Identity/IUserClaimStore.cs
@@ -20,8 +20,7 @@ namespace Microsoft.AspNet.Identity
///
///
///
- Task> GetClaimsAsync(TUser user,
- CancellationToken cancellationToken = default(CancellationToken));
+ Task> GetClaimsAsync(TUser user, CancellationToken cancellationToken);
///
/// Add a new user claim
@@ -30,7 +29,7 @@ namespace Microsoft.AspNet.Identity
///
///
///
- Task AddClaimsAsync(TUser user, IEnumerable claims, CancellationToken cancellationToken = default(CancellationToken));
+ Task AddClaimsAsync(TUser user, IEnumerable claims, CancellationToken cancellationToken);
///
/// Updates the give claim information with the given new claim information
@@ -40,7 +39,7 @@ namespace Microsoft.AspNet.Identity
///
///
///
- Task ReplaceClaimAsync(TUser user, Claim claim, Claim newClaim, CancellationToken cancellationToken = default(CancellationToken));
+ Task ReplaceClaimAsync(TUser user, Claim claim, Claim newClaim, CancellationToken cancellationToken);
///
/// Remove a user claim
@@ -49,8 +48,7 @@ namespace Microsoft.AspNet.Identity
///
///
///
- Task RemoveClaimsAsync(TUser user, IEnumerable claims,
- CancellationToken cancellationToken = default(CancellationToken));
+ Task RemoveClaimsAsync(TUser user, IEnumerable claims, CancellationToken cancellationToken);
///
/// Get users having a specific claim
@@ -58,6 +56,6 @@ namespace Microsoft.AspNet.Identity
/// Claim to look up
///
///
- Task> GetUsersForClaimAsync(Claim claim, CancellationToken cancellationToken = default(CancellationToken));
+ Task> GetUsersForClaimAsync(Claim claim, CancellationToken cancellationToken);
}
}
\ No newline at end of file
diff --git a/src/Microsoft.AspNet.Identity/IUserEmailStore.cs b/src/Microsoft.AspNet.Identity/IUserEmailStore.cs
index 816f9383eb..e3cf5e4595 100644
--- a/src/Microsoft.AspNet.Identity/IUserEmailStore.cs
+++ b/src/Microsoft.AspNet.Identity/IUserEmailStore.cs
@@ -19,7 +19,7 @@ namespace Microsoft.AspNet.Identity
///
///
///
- Task SetEmailAsync(TUser user, string email, CancellationToken cancellationToken = default(CancellationToken));
+ Task SetEmailAsync(TUser user, string email, CancellationToken cancellationToken);
///
/// Get the user email
@@ -27,7 +27,7 @@ namespace Microsoft.AspNet.Identity
///
///
///
- Task GetEmailAsync(TUser user, CancellationToken cancellationToken = default(CancellationToken));
+ Task GetEmailAsync(TUser user, CancellationToken cancellationToken);
///
/// Returns true if the user email is confirmed
@@ -35,8 +35,7 @@ namespace Microsoft.AspNet.Identity
///
///
///
- Task GetEmailConfirmedAsync(TUser user,
- CancellationToken cancellationToken = default(CancellationToken));
+ Task GetEmailConfirmedAsync(TUser user, CancellationToken cancellationToken);
///
/// Sets whether the user email is confirmed
@@ -45,8 +44,7 @@ namespace Microsoft.AspNet.Identity
///
///
///
- Task SetEmailConfirmedAsync(TUser user, bool confirmed,
- CancellationToken cancellationToken = default(CancellationToken));
+ Task SetEmailConfirmedAsync(TUser user, bool confirmed, CancellationToken cancellationToken);
///
/// Returns the user associated with this email
@@ -54,7 +52,7 @@ namespace Microsoft.AspNet.Identity
///
///
///
- Task FindByEmailAsync(string normalizedEmail, CancellationToken cancellationToken = default(CancellationToken));
+ Task FindByEmailAsync(string normalizedEmail, CancellationToken cancellationToken);
///
/// Returns the normalized email
@@ -62,7 +60,7 @@ namespace Microsoft.AspNet.Identity
///
///
///
- Task GetNormalizedEmailAsync(TUser user, CancellationToken cancellationToken = default(CancellationToken));
+ Task GetNormalizedEmailAsync(TUser user, CancellationToken cancellationToken);
///
/// Set the normalized email
@@ -71,8 +69,6 @@ namespace Microsoft.AspNet.Identity
///
///
///
- Task SetNormalizedEmailAsync(TUser user, string normalizedEmail,
- CancellationToken cancellationToken = default(CancellationToken));
-
+ Task SetNormalizedEmailAsync(TUser user, string normalizedEmail, CancellationToken cancellationToken);
}
}
\ No newline at end of file
diff --git a/src/Microsoft.AspNet.Identity/IUserLockoutStore.cs b/src/Microsoft.AspNet.Identity/IUserLockoutStore.cs
index 9ccd0a9afd..7624fe8b70 100644
--- a/src/Microsoft.AspNet.Identity/IUserLockoutStore.cs
+++ b/src/Microsoft.AspNet.Identity/IUserLockoutStore.cs
@@ -20,8 +20,7 @@ namespace Microsoft.AspNet.Identity
///
///
///
- Task GetLockoutEndDateAsync(TUser user,
- CancellationToken cancellationToken = default(CancellationToken));
+ Task GetLockoutEndDateAsync(TUser user, CancellationToken cancellationToken);
///
/// Locks a user out until the specified end date (set to a past date, to unlock a user)
@@ -30,8 +29,7 @@ namespace Microsoft.AspNet.Identity
///
///
///
- Task SetLockoutEndDateAsync(TUser user, DateTimeOffset? lockoutEnd,
- CancellationToken cancellationToken = default(CancellationToken));
+ Task SetLockoutEndDateAsync(TUser user, DateTimeOffset? lockoutEnd, CancellationToken cancellationToken);
///
/// Used to record when an attempt to access the user has failed
@@ -39,8 +37,7 @@ namespace Microsoft.AspNet.Identity
///
///
///
- Task IncrementAccessFailedCountAsync(TUser user,
- CancellationToken cancellationToken = default(CancellationToken));
+ Task IncrementAccessFailedCountAsync(TUser user, CancellationToken cancellationToken);
///
/// Used to reset the account access count, typically after the account is successfully accessed
@@ -48,7 +45,7 @@ namespace Microsoft.AspNet.Identity
///
///
///
- Task ResetAccessFailedCountAsync(TUser user, CancellationToken cancellationToken = default(CancellationToken));
+ Task ResetAccessFailedCountAsync(TUser user, CancellationToken cancellationToken);
///
/// Returns the current number of failed access attempts. This number usually will be reset whenever the
@@ -57,8 +54,7 @@ namespace Microsoft.AspNet.Identity
///
///
///
- Task GetAccessFailedCountAsync(TUser user,
- CancellationToken cancellationToken = default(CancellationToken));
+ Task GetAccessFailedCountAsync(TUser user, CancellationToken cancellationToken);
///
/// Returns whether the user can be locked out.
@@ -66,8 +62,7 @@ namespace Microsoft.AspNet.Identity
///
///
///
- Task GetLockoutEnabledAsync(TUser user,
- CancellationToken cancellationToken = default(CancellationToken));
+ Task GetLockoutEnabledAsync(TUser user, CancellationToken cancellationToken);
///
/// Sets whether the user can be locked out.
@@ -76,7 +71,6 @@ namespace Microsoft.AspNet.Identity
///
///
///
- Task SetLockoutEnabledAsync(TUser user, bool enabled,
- CancellationToken cancellationToken = default(CancellationToken));
+ Task SetLockoutEnabledAsync(TUser user, bool enabled, CancellationToken cancellationToken);
}
}
\ No newline at end of file
diff --git a/src/Microsoft.AspNet.Identity/IUserLoginStore.cs b/src/Microsoft.AspNet.Identity/IUserLoginStore.cs
index c9526f6863..da9accc67d 100644
--- a/src/Microsoft.AspNet.Identity/IUserLoginStore.cs
+++ b/src/Microsoft.AspNet.Identity/IUserLoginStore.cs
@@ -20,8 +20,7 @@ namespace Microsoft.AspNet.Identity
///
///
///
- Task AddLoginAsync(TUser user, UserLoginInfo login,
- CancellationToken cancellationToken = default(CancellationToken));
+ Task AddLoginAsync(TUser user, UserLoginInfo login, CancellationToken cancellationToken);
///
/// Removes the user login with the specified combination if it exists, returns true if found and removed
@@ -31,8 +30,7 @@ namespace Microsoft.AspNet.Identity
///
///
///
- Task RemoveLoginAsync(TUser user, string loginProvider, string providerKey,
- CancellationToken cancellationToken = default(CancellationToken));
+ Task RemoveLoginAsync(TUser user, string loginProvider, string providerKey, CancellationToken cancellationToken);
///
/// Returns the linked accounts for this user
@@ -40,8 +38,7 @@ namespace Microsoft.AspNet.Identity
///
///
///
- Task> GetLoginsAsync(TUser user,
- CancellationToken cancellationToken = default(CancellationToken));
+ Task> GetLoginsAsync(TUser user, CancellationToken cancellationToken);
///
/// Returns the user associated with this login
@@ -50,7 +47,6 @@ namespace Microsoft.AspNet.Identity
///
///
///
- Task FindByLoginAsync(string loginProvider, string providerKey,
- CancellationToken cancellationToken = default(CancellationToken));
+ Task FindByLoginAsync(string loginProvider, string providerKey, CancellationToken cancellationToken);
}
}
\ No newline at end of file
diff --git a/src/Microsoft.AspNet.Identity/IUserPasswordStore.cs b/src/Microsoft.AspNet.Identity/IUserPasswordStore.cs
index 8873e4af49..08d798839a 100644
--- a/src/Microsoft.AspNet.Identity/IUserPasswordStore.cs
+++ b/src/Microsoft.AspNet.Identity/IUserPasswordStore.cs
@@ -19,8 +19,7 @@ namespace Microsoft.AspNet.Identity
///
///
///
- Task SetPasswordHashAsync(TUser user, string passwordHash,
- CancellationToken cancellationToken = default(CancellationToken));
+ Task SetPasswordHashAsync(TUser user, string passwordHash, CancellationToken cancellationToken);
///
/// Get the user password hash
@@ -28,8 +27,7 @@ namespace Microsoft.AspNet.Identity
///
///
///
- Task GetPasswordHashAsync(TUser user,
- CancellationToken cancellationToken = default(CancellationToken));
+ Task GetPasswordHashAsync(TUser user, CancellationToken cancellationToken);
///
/// Returns true if a user has a password set
@@ -37,6 +35,6 @@ namespace Microsoft.AspNet.Identity
///
///
///
- Task HasPasswordAsync(TUser user, CancellationToken cancellationToken = default(CancellationToken));
+ Task HasPasswordAsync(TUser user, CancellationToken cancellationToken);
}
}
\ No newline at end of file
diff --git a/src/Microsoft.AspNet.Identity/IUserPhoneNumberStore.cs b/src/Microsoft.AspNet.Identity/IUserPhoneNumberStore.cs
index a3067c379c..dab00412e5 100644
--- a/src/Microsoft.AspNet.Identity/IUserPhoneNumberStore.cs
+++ b/src/Microsoft.AspNet.Identity/IUserPhoneNumberStore.cs
@@ -19,8 +19,7 @@ namespace Microsoft.AspNet.Identity
///
///
///
- Task SetPhoneNumberAsync(TUser user, string phoneNumber,
- CancellationToken cancellationToken = default(CancellationToken));
+ Task SetPhoneNumberAsync(TUser user, string phoneNumber, CancellationToken cancellationToken);
///
/// Get the user phoneNumber
@@ -28,7 +27,7 @@ namespace Microsoft.AspNet.Identity
///
///
///
- Task GetPhoneNumberAsync(TUser user, CancellationToken cancellationToken = default(CancellationToken));
+ Task GetPhoneNumberAsync(TUser user, CancellationToken cancellationToken);
///
/// Returns true if the user phone number is confirmed
@@ -36,8 +35,7 @@ namespace Microsoft.AspNet.Identity
///
///
///
- Task GetPhoneNumberConfirmedAsync(TUser user,
- CancellationToken cancellationToken = default(CancellationToken));
+ Task GetPhoneNumberConfirmedAsync(TUser user, CancellationToken cancellationToken);
///
/// Sets whether the user phone number is confirmed
@@ -46,7 +44,6 @@ namespace Microsoft.AspNet.Identity
///
///
///
- Task SetPhoneNumberConfirmedAsync(TUser user, bool confirmed,
- CancellationToken cancellationToken = default(CancellationToken));
+ Task SetPhoneNumberConfirmedAsync(TUser user, bool confirmed, CancellationToken cancellationToken);
}
}
\ No newline at end of file
diff --git a/src/Microsoft.AspNet.Identity/IUserRoleStore.cs b/src/Microsoft.AspNet.Identity/IUserRoleStore.cs
index 690eeeb45a..6e451b51fe 100644
--- a/src/Microsoft.AspNet.Identity/IUserRoleStore.cs
+++ b/src/Microsoft.AspNet.Identity/IUserRoleStore.cs
@@ -20,8 +20,7 @@ namespace Microsoft.AspNet.Identity
///
///
///
- Task AddToRoleAsync(TUser user, string roleName,
- CancellationToken cancellationToken = default(CancellationToken));
+ Task AddToRoleAsync(TUser user, string roleName, CancellationToken cancellationToken);
///
/// Removes the role for the user
@@ -30,8 +29,7 @@ namespace Microsoft.AspNet.Identity
///
///
///
- Task RemoveFromRoleAsync(TUser user, string roleName,
- CancellationToken cancellationToken = default(CancellationToken));
+ Task RemoveFromRoleAsync(TUser user, string roleName, CancellationToken cancellationToken);
///
/// Returns the roles for this user
@@ -39,8 +37,7 @@ namespace Microsoft.AspNet.Identity
///
///
///
- Task> GetRolesAsync(TUser user,
- CancellationToken cancellationToken = default(CancellationToken));
+ Task> GetRolesAsync(TUser user, CancellationToken cancellationToken);
///
/// Returns true if a user is in a role
@@ -49,8 +46,7 @@ namespace Microsoft.AspNet.Identity
///
///
///
- Task IsInRoleAsync(TUser user, string roleName,
- CancellationToken cancellationToken = default(CancellationToken));
+ Task IsInRoleAsync(TUser user, string roleName, CancellationToken cancellationToken);
///
/// Returns all users in given role
@@ -58,6 +54,6 @@ namespace Microsoft.AspNet.Identity
///
///
///
- Task> GetUsersInRoleAsync(string roleName, CancellationToken cancellationToken = default(CancellationToken));
+ Task> GetUsersInRoleAsync(string roleName, CancellationToken cancellationToken);
}
}
\ No newline at end of file
diff --git a/src/Microsoft.AspNet.Identity/IUserSecurityStampStore.cs b/src/Microsoft.AspNet.Identity/IUserSecurityStampStore.cs
index fc6f57b0b3..70e6e08ded 100644
--- a/src/Microsoft.AspNet.Identity/IUserSecurityStampStore.cs
+++ b/src/Microsoft.AspNet.Identity/IUserSecurityStampStore.cs
@@ -19,8 +19,7 @@ namespace Microsoft.AspNet.Identity
///
///
///
- Task SetSecurityStampAsync(TUser user, string stamp,
- CancellationToken cancellationToken = default(CancellationToken));
+ Task SetSecurityStampAsync(TUser user, string stamp, CancellationToken cancellationToken);
///
/// Get the user security stamp
@@ -28,7 +27,6 @@ namespace Microsoft.AspNet.Identity
///
///
///
- Task GetSecurityStampAsync(TUser user,
- CancellationToken cancellationToken = default(CancellationToken));
+ Task GetSecurityStampAsync(TUser user, CancellationToken cancellationToken);
}
}
\ No newline at end of file
diff --git a/src/Microsoft.AspNet.Identity/IUserStore.cs b/src/Microsoft.AspNet.Identity/IUserStore.cs
index d6cd313733..74f8ddef60 100644
--- a/src/Microsoft.AspNet.Identity/IUserStore.cs
+++ b/src/Microsoft.AspNet.Identity/IUserStore.cs
@@ -19,7 +19,7 @@ namespace Microsoft.AspNet.Identity
///
///
///
- Task GetUserIdAsync(TUser user, CancellationToken cancellationToken = default(CancellationToken));
+ Task GetUserIdAsync(TUser user, CancellationToken cancellationToken);
///
/// Returns the user's name
@@ -27,7 +27,7 @@ namespace Microsoft.AspNet.Identity
///
///
///
- Task GetUserNameAsync(TUser user, CancellationToken cancellationToken = default(CancellationToken));
+ Task GetUserNameAsync(TUser user, CancellationToken cancellationToken);
///
/// Set the user name
@@ -37,7 +37,7 @@ namespace Microsoft.AspNet.Identity
///
///
Task SetUserNameAsync(TUser user, string userName,
- CancellationToken cancellationToken = default(CancellationToken));
+ CancellationToken cancellationToken);
///
/// Returns the normalized user name
@@ -45,7 +45,7 @@ namespace Microsoft.AspNet.Identity
///
///
///
- Task GetNormalizedUserNameAsync(TUser user, CancellationToken cancellationToken = default(CancellationToken));
+ Task GetNormalizedUserNameAsync(TUser user, CancellationToken cancellationToken);
///
/// Set the normalized user name
@@ -55,7 +55,7 @@ namespace Microsoft.AspNet.Identity
///
///
Task SetNormalizedUserNameAsync(TUser user, string normalizedName,
- CancellationToken cancellationToken = default(CancellationToken));
+ CancellationToken cancellationToken);
///
/// Insert a new user
@@ -63,7 +63,7 @@ namespace Microsoft.AspNet.Identity
///
///
///
- Task CreateAsync(TUser user, CancellationToken cancellationToken = default(CancellationToken));
+ Task CreateAsync(TUser user, CancellationToken cancellationToken);
///
/// UpdateAsync a user
@@ -71,7 +71,7 @@ namespace Microsoft.AspNet.Identity
///
///
///
- Task UpdateAsync(TUser user, CancellationToken cancellationToken = default(CancellationToken));
+ Task UpdateAsync(TUser user, CancellationToken cancellationToken);
///
/// DeleteAsync a user
@@ -79,7 +79,7 @@ namespace Microsoft.AspNet.Identity
///
///
///
- Task DeleteAsync(TUser user, CancellationToken cancellationToken = default(CancellationToken));
+ Task DeleteAsync(TUser user, CancellationToken cancellationToken);
///
/// Finds a user
@@ -87,7 +87,7 @@ namespace Microsoft.AspNet.Identity
///
///
///
- Task FindByIdAsync(string userId, CancellationToken cancellationToken = default(CancellationToken));
+ Task FindByIdAsync(string userId, CancellationToken cancellationToken);
///
/// Returns the user associated with this normalized user name
@@ -95,6 +95,6 @@ namespace Microsoft.AspNet.Identity
///
///
///
- Task FindByNameAsync(string normalizedUserName, CancellationToken cancellationToken = default(CancellationToken));
+ Task FindByNameAsync(string normalizedUserName, CancellationToken cancellationToken);
}
}
\ No newline at end of file
diff --git a/src/Microsoft.AspNet.Identity/IUserTokenProvider.cs b/src/Microsoft.AspNet.Identity/IUserTokenProvider.cs
index 7b03c5c584..d785f41bd5 100644
--- a/src/Microsoft.AspNet.Identity/IUserTokenProvider.cs
+++ b/src/Microsoft.AspNet.Identity/IUserTokenProvider.cs
@@ -22,10 +22,8 @@ namespace Microsoft.AspNet.Identity
///
///
///
- ///
///
- Task GenerateAsync(string purpose, UserManager manager, TUser user,
- CancellationToken cancellationToken = default(CancellationToken));
+ Task GenerateAsync(string purpose, UserManager manager, TUser user);
///
/// ValidateAsync and unprotect a token, returns null if invalid
@@ -34,10 +32,8 @@ namespace Microsoft.AspNet.Identity
///
///
///
- ///
///
- Task ValidateAsync(string purpose, string token, UserManager manager, TUser user,
- CancellationToken cancellationToken = default(CancellationToken));
+ Task ValidateAsync(string purpose, string token, UserManager manager, TUser user);
///
/// Notifies the user that a token has been generated, i.e. via email or sms, or can no-op
@@ -45,19 +41,15 @@ namespace Microsoft.AspNet.Identity
///
///
///
- ///
///
- Task NotifyAsync(string token, UserManager manager, TUser user,
- CancellationToken cancellationToken = default(CancellationToken));
+ Task NotifyAsync(string token, UserManager manager, TUser user);
///
/// Returns true if provider can be used for this user to generate two factor tokens, i.e. could require a user to have an email
///
///
///
- ///
///
- Task CanGenerateTwoFactorTokenAsync(UserManager manager, TUser user,
- CancellationToken cancellationToken = default(CancellationToken));
+ Task CanGenerateTwoFactorTokenAsync(UserManager manager, TUser user);
}
}
\ No newline at end of file
diff --git a/src/Microsoft.AspNet.Identity/IUserTwoFactorStore.cs b/src/Microsoft.AspNet.Identity/IUserTwoFactorStore.cs
index c8b3516602..592963cd5c 100644
--- a/src/Microsoft.AspNet.Identity/IUserTwoFactorStore.cs
+++ b/src/Microsoft.AspNet.Identity/IUserTwoFactorStore.cs
@@ -19,8 +19,7 @@ namespace Microsoft.AspNet.Identity
///
///
///
- Task SetTwoFactorEnabledAsync(TUser user, bool enabled,
- CancellationToken cancellationToken = default(CancellationToken));
+ Task SetTwoFactorEnabledAsync(TUser user, bool enabled, CancellationToken cancellationToken);
///
/// Returns whether two factor is enabled for the user
@@ -28,7 +27,6 @@ namespace Microsoft.AspNet.Identity
///
///
///
- Task GetTwoFactorEnabledAsync(TUser user,
- CancellationToken cancellationToken = default(CancellationToken));
+ Task GetTwoFactorEnabledAsync(TUser user, CancellationToken cancellationToken);
}
}
\ No newline at end of file
diff --git a/src/Microsoft.AspNet.Identity/IUserValidator.cs b/src/Microsoft.AspNet.Identity/IUserValidator.cs
index b0d2861839..e4e4e3683b 100644
--- a/src/Microsoft.AspNet.Identity/IUserValidator.cs
+++ b/src/Microsoft.AspNet.Identity/IUserValidator.cs
@@ -1,7 +1,6 @@
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-using System;
using System.Threading;
using System.Threading.Tasks;
@@ -20,7 +19,6 @@ namespace Microsoft.AspNet.Identity
///
///
///
- Task ValidateAsync(UserManager manager, TUser user,
- CancellationToken cancellationToken = default(CancellationToken));
+ Task ValidateAsync(UserManager manager, TUser user);
}
}
\ No newline at end of file
diff --git a/src/Microsoft.AspNet.Identity/PasswordValidator.cs b/src/Microsoft.AspNet.Identity/PasswordValidator.cs
index 1726e26694..eae00f966e 100644
--- a/src/Microsoft.AspNet.Identity/PasswordValidator.cs
+++ b/src/Microsoft.AspNet.Identity/PasswordValidator.cs
@@ -28,8 +28,7 @@ namespace Microsoft.AspNet.Identity
///
///
///
- public virtual Task ValidateAsync(UserManager manager, TUser user, string password,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual Task ValidateAsync(UserManager manager, TUser user, string password)
{
if (password == null)
{
diff --git a/src/Microsoft.AspNet.Identity/PhoneNumberTokenProvider.cs b/src/Microsoft.AspNet.Identity/PhoneNumberTokenProvider.cs
index 3116bc5dd3..cec3f7740a 100644
--- a/src/Microsoft.AspNet.Identity/PhoneNumberTokenProvider.cs
+++ b/src/Microsoft.AspNet.Identity/PhoneNumberTokenProvider.cs
@@ -1,6 +1,5 @@
using System;
using System.Globalization;
-using System.Threading;
using System.Threading.Tasks;
using Microsoft.Framework.OptionsModel;
@@ -44,15 +43,14 @@ namespace Microsoft.AspNet.Identity
///
///
///
- public override async Task CanGenerateTwoFactorTokenAsync(UserManager manager, TUser user,
- CancellationToken cancellationToken = default(CancellationToken))
+ public override async Task CanGenerateTwoFactorTokenAsync(UserManager manager, TUser user)
{
if (manager == null)
{
throw new ArgumentNullException("manager");
}
- var phoneNumber = await manager.GetPhoneNumberAsync(user, cancellationToken);
- return !string.IsNullOrWhiteSpace(phoneNumber) && await manager.IsPhoneNumberConfirmedAsync(user, cancellationToken);
+ var phoneNumber = await manager.GetPhoneNumberAsync(user);
+ return !string.IsNullOrWhiteSpace(phoneNumber) && await manager.IsPhoneNumberConfirmedAsync(user);
}
///
@@ -62,14 +60,13 @@ namespace Microsoft.AspNet.Identity
///
///
///
- public override async Task GetUserModifierAsync(string purpose, UserManager manager,
- TUser user, CancellationToken cancellationToken = default(CancellationToken))
+ public override async Task GetUserModifierAsync(string purpose, UserManager manager, TUser user)
{
if (manager == null)
{
throw new ArgumentNullException("manager");
}
- var phoneNumber = await manager.GetPhoneNumberAsync(user, cancellationToken);
+ var phoneNumber = await manager.GetPhoneNumberAsync(user);
return "PhoneNumber:" + purpose + ":" + phoneNumber;
}
@@ -80,8 +77,7 @@ namespace Microsoft.AspNet.Identity
///
///
///
- public override async Task NotifyAsync(string token, UserManager manager, TUser user,
- CancellationToken cancellationToken = default(CancellationToken))
+ public override async Task NotifyAsync(string token, UserManager manager, TUser user)
{
if (manager == null)
{
@@ -89,10 +85,10 @@ namespace Microsoft.AspNet.Identity
}
var msg = new IdentityMessage
{
- Destination = await manager.GetPhoneNumberAsync(user, cancellationToken),
+ Destination = await manager.GetPhoneNumberAsync(user),
Body = string.Format(CultureInfo.CurrentCulture, Options.MessageFormat, token)
};
- await manager.SendMessageAsync(Options.MessageProvider, msg, cancellationToken);
+ await manager.SendMessageAsync(Options.MessageProvider, msg);
}
}
}
\ No newline at end of file
diff --git a/src/Microsoft.AspNet.Identity/RoleManager.cs b/src/Microsoft.AspNet.Identity/RoleManager.cs
index bc53a116ca..848fc21d55 100644
--- a/src/Microsoft.AspNet.Identity/RoleManager.cs
+++ b/src/Microsoft.AspNet.Identity/RoleManager.cs
@@ -7,6 +7,8 @@ using System.Linq;
using System.Security.Claims;
using System.Threading;
using System.Threading.Tasks;
+using Microsoft.AspNet.Hosting;
+using Microsoft.AspNet.Http;
using Microsoft.Framework.Logging;
namespace Microsoft.AspNet.Identity
@@ -18,6 +20,7 @@ namespace Microsoft.AspNet.Identity
public class RoleManager : IDisposable where TRole : class
{
private bool _disposed;
+ private HttpContext _context;
///
/// Constructor
@@ -28,7 +31,8 @@ namespace Microsoft.AspNet.Identity
IEnumerable> roleValidators = null,
ILookupNormalizer keyNormalizer = null,
IdentityErrorDescriber errors = null,
- ILogger> logger = null)
+ ILogger> logger = null,
+ IHttpContextAccessor contextAccessor = null)
{
if (store == null)
{
@@ -37,6 +41,7 @@ namespace Microsoft.AspNet.Identity
Store = store;
KeyNormalizer = keyNormalizer ?? new UpperInvariantLookupNormalizer();
ErrorDescriber = errors ?? new IdentityErrorDescriber();
+ _context = contextAccessor?.Value;
if (roleValidators != null)
{
@@ -114,6 +119,14 @@ namespace Microsoft.AspNet.Identity
}
}
+ private CancellationToken CancellationToken
+ {
+ get
+ {
+ return _context?.RequestAborted ?? CancellationToken.None;
+ }
+ }
+
///
/// Dispose this object
///
@@ -123,12 +136,12 @@ namespace Microsoft.AspNet.Identity
GC.SuppressFinalize(this);
}
- private async Task ValidateRoleInternal(TRole role, CancellationToken cancellationToken)
+ private async Task ValidateRoleInternal(TRole role)
{
var errors = new List();
foreach (var v in RoleValidators)
{
- var result = await v.ValidateAsync(this, role, cancellationToken);
+ var result = await v.ValidateAsync(this, role);
if (!result.Succeeded)
{
errors.AddRange(result.Errors);
@@ -138,13 +151,11 @@ namespace Microsoft.AspNet.Identity
}
///
- /// CreateAsync a role
+ /// Create a role
///
///
- ///
///
- public virtual async Task CreateAsync(TRole role,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task CreateAsync(TRole role)
{
ThrowIfDisposed();
if (role == null)
@@ -152,37 +163,33 @@ namespace Microsoft.AspNet.Identity
throw new ArgumentNullException("role");
}
- var result = await ValidateRoleInternal(role, cancellationToken);
+ var result = await ValidateRoleInternal(role);
if (!result.Succeeded)
{
return result;
}
- await UpdateNormalizedRoleNameAsync(role, cancellationToken);
- return await LogResultAsync(await Store.CreateAsync(role, cancellationToken), role);
+ await UpdateNormalizedRoleNameAsync(role);
+ return await LogResultAsync(await Store.CreateAsync(role, CancellationToken), role);
}
///
/// Update the user's normalized user name
///
///
- ///
///
- public virtual async Task UpdateNormalizedRoleNameAsync(TRole role,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task UpdateNormalizedRoleNameAsync(TRole role)
{
- var name = await GetRoleNameAsync(role, cancellationToken);
- await Store.SetNormalizedRoleNameAsync(role, NormalizeKey(name), cancellationToken);
+ var name = await GetRoleNameAsync(role);
+ await Store.SetNormalizedRoleNameAsync(role, NormalizeKey(name), CancellationToken);
}
///
- /// UpdateAsync an existing role
+ /// Update an existing role
///
///
- ///
///
- public virtual async Task UpdateAsync(TRole role,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task UpdateAsync(TRole role)
{
ThrowIfDisposed();
if (role == null)
@@ -190,46 +197,41 @@ namespace Microsoft.AspNet.Identity
throw new ArgumentNullException("role");
}
- return await LogResultAsync(await UpdateRoleAsync(role, cancellationToken), role);
+ return await LogResultAsync(await UpdateRoleAsync(role), role);
}
- private async Task UpdateRoleAsync(TRole role,
- CancellationToken cancellationToken = default(CancellationToken))
+ private async Task UpdateRoleAsync(TRole role)
{
- var result = await ValidateRoleInternal(role, cancellationToken);
+ var result = await ValidateRoleInternal(role);
if (!result.Succeeded)
{
return result;
}
- await UpdateNormalizedRoleNameAsync(role, cancellationToken);
- return await Store.UpdateAsync(role, cancellationToken);
+ await UpdateNormalizedRoleNameAsync(role);
+ return await Store.UpdateAsync(role, CancellationToken);
}
///
- /// DeleteAsync a role
+ /// Delete a role
///
///
- ///
///
- public virtual async Task DeleteAsync(TRole role,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task DeleteAsync(TRole role)
{
ThrowIfDisposed();
if (role == null)
{
throw new ArgumentNullException("role");
}
- return await LogResultAsync(await Store.DeleteAsync(role, cancellationToken), role);
+ return await LogResultAsync(await Store.DeleteAsync(role, CancellationToken), role);
}
///
/// Returns true if the role exists
///
///
- ///
///
- public virtual async Task RoleExistsAsync(string roleName,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task RoleExistsAsync(string roleName)
{
ThrowIfDisposed();
if (roleName == null)
@@ -237,7 +239,7 @@ namespace Microsoft.AspNet.Identity
throw new ArgumentNullException("roleName");
}
- return await FindByNameAsync(NormalizeKey(roleName), cancellationToken) != null;
+ return await FindByNameAsync(NormalizeKey(roleName)) != null;
}
///
@@ -252,29 +254,25 @@ namespace Microsoft.AspNet.Identity
///
- /// FindByLoginAsync a role by id
+ /// Find a role by id
///
///
- ///
///
- public virtual async Task FindByIdAsync(string roleId,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task FindByIdAsync(string roleId)
{
ThrowIfDisposed();
- return await Store.FindByIdAsync(roleId, cancellationToken);
+ return await Store.FindByIdAsync(roleId, CancellationToken);
}
///
/// Return the name of the role
///
///
- ///
///
- public virtual async Task GetRoleNameAsync(TRole role,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task GetRoleNameAsync(TRole role)
{
ThrowIfDisposed();
- return await Store.GetRoleNameAsync(role, cancellationToken);
+ return await Store.GetRoleNameAsync(role, CancellationToken);
}
///
@@ -282,14 +280,12 @@ namespace Microsoft.AspNet.Identity
///
///
///
- ///
///
- public virtual async Task SetRoleNameAsync(TRole role, string name,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task SetRoleNameAsync(TRole role, string name)
{
ThrowIfDisposed();
- await Store.SetRoleNameAsync(role, name, cancellationToken);
- await UpdateNormalizedRoleNameAsync(role, cancellationToken);
+ await Store.SetRoleNameAsync(role, name, CancellationToken);
+ await UpdateNormalizedRoleNameAsync(role);
return await LogResultAsync(IdentityResult.Success, role);
}
@@ -297,23 +293,19 @@ namespace Microsoft.AspNet.Identity
/// Return the role id for a role
///
///
- ///
///
- public virtual async Task GetRoleIdAsync(TRole role,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task GetRoleIdAsync(TRole role)
{
ThrowIfDisposed();
- return await Store.GetRoleIdAsync(role, cancellationToken);
+ return await Store.GetRoleIdAsync(role, CancellationToken);
}
///
/// FindByLoginAsync a role by name
///
///
- ///
///
- public virtual async Task FindByNameAsync(string roleName,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task FindByNameAsync(string roleName)
{
ThrowIfDisposed();
if (roleName == null)
@@ -321,7 +313,7 @@ namespace Microsoft.AspNet.Identity
throw new ArgumentNullException("roleName");
}
- return await Store.FindByNameAsync(NormalizeKey(roleName), cancellationToken);
+ return await Store.FindByNameAsync(NormalizeKey(roleName), CancellationToken);
}
// IRoleClaimStore methods
@@ -340,10 +332,8 @@ namespace Microsoft.AspNet.Identity
///
///
///
- ///
///
- public virtual async Task AddClaimAsync(TRole role, Claim claim,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task AddClaimAsync(TRole role, Claim claim)
{
ThrowIfDisposed();
var claimStore = GetClaimStore();
@@ -355,8 +345,8 @@ namespace Microsoft.AspNet.Identity
{
throw new ArgumentNullException("role");
}
- await claimStore.AddClaimAsync(role, claim, cancellationToken);
- return await LogResultAsync(await UpdateRoleAsync(role, cancellationToken), role);
+ await claimStore.AddClaimAsync(role, claim, CancellationToken);
+ return await LogResultAsync(await UpdateRoleAsync(role), role);
}
///
@@ -364,10 +354,8 @@ namespace Microsoft.AspNet.Identity
///
///
///
- ///
///
- public virtual async Task RemoveClaimAsync(TRole role, Claim claim,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task RemoveClaimAsync(TRole role, Claim claim)
{
ThrowIfDisposed();
var claimStore = GetClaimStore();
@@ -375,18 +363,16 @@ namespace Microsoft.AspNet.Identity
{
throw new ArgumentNullException("role");
}
- await claimStore.RemoveClaimAsync(role, claim, cancellationToken);
- return await LogResultAsync(await UpdateRoleAsync(role, cancellationToken), role);
+ await claimStore.RemoveClaimAsync(role, claim, CancellationToken);
+ return await LogResultAsync(await UpdateRoleAsync(role), role);
}
///
/// Get a role's claims
///
///
- ///
///
- public virtual async Task> GetClaimsAsync(TRole role,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task> GetClaimsAsync(TRole role)
{
ThrowIfDisposed();
var claimStore = GetClaimStore();
@@ -394,7 +380,7 @@ namespace Microsoft.AspNet.Identity
{
throw new ArgumentNullException("role");
}
- return await claimStore.GetClaimsAsync(role, cancellationToken);
+ return await claimStore.GetClaimsAsync(role, CancellationToken);
}
///
diff --git a/src/Microsoft.AspNet.Identity/RoleValidator.cs b/src/Microsoft.AspNet.Identity/RoleValidator.cs
index fc20865ae9..e8965dd767 100644
--- a/src/Microsoft.AspNet.Identity/RoleValidator.cs
+++ b/src/Microsoft.AspNet.Identity/RoleValidator.cs
@@ -3,7 +3,6 @@
using System;
using System.Collections.Generic;
-using System.Threading;
using System.Threading.Tasks;
namespace Microsoft.AspNet.Identity
@@ -28,8 +27,7 @@ namespace Microsoft.AspNet.Identity
///
///
///
- public virtual async Task ValidateAsync(RoleManager manager, TRole role,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task ValidateAsync(RoleManager manager, TRole role)
{
if (manager == null)
{
diff --git a/src/Microsoft.AspNet.Identity/SecurityStampValidator.cs b/src/Microsoft.AspNet.Identity/SecurityStampValidator.cs
index 73323893d4..1b6abbdf4f 100644
--- a/src/Microsoft.AspNet.Identity/SecurityStampValidator.cs
+++ b/src/Microsoft.AspNet.Identity/SecurityStampValidator.cs
@@ -19,12 +19,11 @@ namespace Microsoft.AspNet.Identity
/// ClaimsIdentity
///
///
- public virtual async Task ValidateAsync(CookieValidateIdentityContext context, ClaimsIdentity identity,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task ValidateAsync(CookieValidateIdentityContext context, ClaimsIdentity identity)
{
var manager = context.HttpContext.RequestServices.GetRequiredService>();
var userId = identity.GetUserId();
- var user = await manager.ValidateSecurityStampAsync(identity, userId, cancellationToken);
+ var user = await manager.ValidateSecurityStampAsync(identity, userId);
if (user != null)
{
var isPersistent = false;
@@ -32,7 +31,7 @@ namespace Microsoft.AspNet.Identity
{
isPersistent = context.Properties.IsPersistent;
}
- await manager.SignInAsync(user, isPersistent, authenticationMethod: null, cancellationToken: cancellationToken);
+ await manager.SignInAsync(user, isPersistent, authenticationMethod: null);
}
else
{
diff --git a/src/Microsoft.AspNet.Identity/SignInManager.cs b/src/Microsoft.AspNet.Identity/SignInManager.cs
index 43a5ed62c7..12e4b9d027 100644
--- a/src/Microsoft.AspNet.Identity/SignInManager.cs
+++ b/src/Microsoft.AspNet.Identity/SignInManager.cs
@@ -6,7 +6,6 @@ using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;
using System.Security.Principal;
-using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNet.Hosting;
using Microsoft.AspNet.Http;
@@ -56,28 +55,25 @@ namespace Microsoft.AspNet.Identity
public ILogger> Logger { get; set; }
// Should this be a func?
- public virtual async Task CreateUserIdentityAsync(TUser user,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task CreateUserIdentityAsync(TUser user)
{
return await ClaimsFactory.CreateAsync(user);
}
- public virtual async Task CanSignInAsync(TUser user,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task CanSignInAsync(TUser user)
{
- if (Options.SignIn.RequireConfirmedEmail && !(await UserManager.IsEmailConfirmedAsync(user, cancellationToken)))
+ if (Options.SignIn.RequireConfirmedEmail && !(await UserManager.IsEmailConfirmedAsync(user)))
{
return await LogResultAsync(false, user);
}
- if (Options.SignIn.RequireConfirmedPhoneNumber && !(await UserManager.IsPhoneNumberConfirmedAsync(user, cancellationToken)))
+ if (Options.SignIn.RequireConfirmedPhoneNumber && !(await UserManager.IsPhoneNumberConfirmedAsync(user)))
{
return await LogResultAsync(false, user);
}
return await LogResultAsync(true, user);
}
- public virtual async Task SignInAsync(TUser user, bool isPersistent, string authenticationMethod = null,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task SignInAsync(TUser user, bool isPersistent, string authenticationMethod = null)
{
var userIdentity = await CreateUserIdentityAsync(user);
if (authenticationMethod != null)
@@ -87,7 +83,6 @@ namespace Microsoft.AspNet.Identity
Context.Response.SignIn(new AuthenticationProperties() { IsPersistent = isPersistent }, userIdentity);
}
- // TODO: Should this be async?
public virtual void SignOut()
{
Context.Response.SignOut(IdentityOptions.ApplicationCookieAuthenticationType);
@@ -95,29 +90,29 @@ namespace Microsoft.AspNet.Identity
Context.Response.SignOut(IdentityOptions.TwoFactorUserIdCookieAuthenticationType);
}
- private async Task IsLockedOut(TUser user, CancellationToken token)
+ private async Task IsLockedOut(TUser user)
{
- return UserManager.SupportsUserLockout && await UserManager.IsLockedOutAsync(user, token);
+ return UserManager.SupportsUserLockout && await UserManager.IsLockedOutAsync(user);
}
- private async Task PreSignInCheck(TUser user, CancellationToken token)
+ private async Task PreSignInCheck(TUser user)
{
- if (!await CanSignInAsync(user, token))
+ if (!await CanSignInAsync(user))
{
return SignInResult.NotAllowed;
}
- if (await IsLockedOut(user, token))
+ if (await IsLockedOut(user))
{
return SignInResult.LockedOut;
}
return null;
}
- private Task ResetLockout(TUser user, CancellationToken token)
+ private Task ResetLockout(TUser user)
{
if (UserManager.SupportsUserLockout)
{
- return UserManager.ResetAccessFailedCountAsync(user, token);
+ return UserManager.ResetAccessFailedCountAsync(user);
}
return Task.FromResult(0);
}
@@ -129,15 +124,14 @@ namespace Microsoft.AspNet.Identity
///
///
///
- public virtual async Task ValidateSecurityStampAsync(ClaimsIdentity identity, string userId,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task ValidateSecurityStampAsync(ClaimsIdentity identity, string userId)
{
- var user = await UserManager.FindByIdAsync(userId, cancellationToken);
+ var user = await UserManager.FindByIdAsync(userId);
if (user != null && UserManager.SupportsUserSecurityStamp)
{
var securityStamp =
identity.FindFirstValue(Options.ClaimsIdentity.SecurityStampClaimType);
- if (securityStamp == await UserManager.GetSecurityStampAsync(user, cancellationToken))
+ if (securityStamp == await UserManager.GetSecurityStampAsync(user))
{
return user;
}
@@ -146,31 +140,31 @@ namespace Microsoft.AspNet.Identity
}
public virtual async Task PasswordSignInAsync(TUser user, string password,
- bool isPersistent, bool shouldLockout, CancellationToken cancellationToken = default(CancellationToken))
+ bool isPersistent, bool shouldLockout)
{
if (user == null)
{
throw new ArgumentNullException(nameof(user));
}
- var error = await PreSignInCheck(user, cancellationToken);
+ var error = await PreSignInCheck(user);
if (error != null)
{
return await LogResultAsync(error, user);
}
- if (await IsLockedOut(user, cancellationToken))
+ if (await IsLockedOut(user))
{
return await LogResultAsync(SignInResult.LockedOut, user);
}
- if (await UserManager.CheckPasswordAsync(user, password, cancellationToken))
+ if (await UserManager.CheckPasswordAsync(user, password))
{
- await ResetLockout(user, cancellationToken);
- return await LogResultAsync(await SignInOrTwoFactorAsync(user, isPersistent, cancellationToken), user);
+ await ResetLockout(user);
+ return await LogResultAsync(await SignInOrTwoFactorAsync(user, isPersistent), user);
}
if (UserManager.SupportsUserLockout && shouldLockout)
{
// If lockout is requested, increment access failed count which might lock out the user
- await UserManager.AccessFailedAsync(user, cancellationToken);
- if (await UserManager.IsLockedOutAsync(user, cancellationToken))
+ await UserManager.AccessFailedAsync(user);
+ if (await UserManager.IsLockedOutAsync(user))
{
return await LogResultAsync(SignInResult.LockedOut, user);
@@ -180,14 +174,14 @@ namespace Microsoft.AspNet.Identity
}
public virtual async Task PasswordSignInAsync(string userName, string password,
- bool isPersistent, bool shouldLockout, CancellationToken cancellationToken = default(CancellationToken))
+ bool isPersistent, bool shouldLockout)
{
- var user = await UserManager.FindByNameAsync(userName, cancellationToken);
+ var user = await UserManager.FindByNameAsync(userName);
if (user == null)
{
return SignInResult.Failed;
}
- return await PasswordSignInAsync(user, password, isPersistent, shouldLockout, cancellationToken);
+ return await PasswordSignInAsync(user, password, isPersistent, shouldLockout);
}
private static ClaimsIdentity CreateIdentity(TwoFactorAuthenticationInfo info)
@@ -205,87 +199,84 @@ namespace Microsoft.AspNet.Identity
return identity;
}
- public virtual async Task SendTwoFactorCodeAsync(string provider,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task SendTwoFactorCodeAsync(string provider)
{
- var twoFactorInfo = await RetrieveTwoFactorInfoAsync(cancellationToken);
+ var twoFactorInfo = await RetrieveTwoFactorInfoAsync();
if (twoFactorInfo == null || twoFactorInfo.UserId == null)
{
return false;
}
- var user = await UserManager.FindByIdAsync(twoFactorInfo.UserId, cancellationToken);
+ var user = await UserManager.FindByIdAsync(twoFactorInfo.UserId);
if (user == null)
{
return false;
}
- var token = await UserManager.GenerateTwoFactorTokenAsync(user, provider, cancellationToken);
- await UserManager.NotifyTwoFactorTokenAsync(user, provider, token, cancellationToken);
+ var token = await UserManager.GenerateTwoFactorTokenAsync(user, provider);
+ await UserManager.NotifyTwoFactorTokenAsync(user, provider, token);
return await LogResultAsync(true, user);
}
- public virtual async Task IsTwoFactorClientRememberedAsync(TUser user,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task IsTwoFactorClientRememberedAsync(TUser user)
{
- var userId = await UserManager.GetUserIdAsync(user, cancellationToken);
+ var userId = await UserManager.GetUserIdAsync(user);
var result =
await Context.AuthenticateAsync(IdentityOptions.TwoFactorRememberMeCookieAuthenticationType);
return (result != null && result.Identity != null && result.Identity.Name == userId);
}
- public virtual async Task RememberTwoFactorClientAsync(TUser user,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task RememberTwoFactorClientAsync(TUser user)
{
- var userId = await UserManager.GetUserIdAsync(user, cancellationToken);
+ var userId = await UserManager.GetUserIdAsync(user);
var rememberBrowserIdentity = new ClaimsIdentity(IdentityOptions.TwoFactorRememberMeCookieAuthenticationType);
rememberBrowserIdentity.AddClaim(new Claim(ClaimTypes.Name, userId));
Context.Response.SignIn(new AuthenticationProperties { IsPersistent = true }, rememberBrowserIdentity);
}
- public virtual Task ForgetTwoFactorClientAsync(CancellationToken cancellationToken = default(CancellationToken))
+ public virtual Task ForgetTwoFactorClientAsync()
{
Context.Response.SignOut(IdentityOptions.TwoFactorRememberMeCookieAuthenticationType);
return Task.FromResult(0);
}
public virtual async Task TwoFactorSignInAsync(string provider, string code, bool isPersistent,
- bool rememberClient, CancellationToken cancellationToken = default(CancellationToken))
+ bool rememberClient)
{
- var twoFactorInfo = await RetrieveTwoFactorInfoAsync(cancellationToken);
+ var twoFactorInfo = await RetrieveTwoFactorInfoAsync();
if (twoFactorInfo == null || twoFactorInfo.UserId == null)
{
return SignInResult.Failed;
}
- var user = await UserManager.FindByIdAsync(twoFactorInfo.UserId, cancellationToken);
+ var user = await UserManager.FindByIdAsync(twoFactorInfo.UserId);
if (user == null)
{
return SignInResult.Failed;
}
- var error = await PreSignInCheck(user, cancellationToken);
+ var error = await PreSignInCheck(user);
if (error != null)
{
return await LogResultAsync(error, user);
}
- if (await UserManager.VerifyTwoFactorTokenAsync(user, provider, code, cancellationToken))
+ if (await UserManager.VerifyTwoFactorTokenAsync(user, provider, code))
{
// When token is verified correctly, clear the access failed count used for lockout
- await ResetLockout(user, cancellationToken);
+ await ResetLockout(user);
// Cleanup external cookie
if (twoFactorInfo.LoginProvider != null)
{
Context.Response.SignOut(IdentityOptions.ExternalCookieAuthenticationType);
}
- await SignInAsync(user, isPersistent, twoFactorInfo.LoginProvider, cancellationToken);
+ await SignInAsync(user, isPersistent, twoFactorInfo.LoginProvider);
if (rememberClient)
{
- await RememberTwoFactorClientAsync(user, cancellationToken);
+ await RememberTwoFactorClientAsync(user);
}
- await UserManager.ResetAccessFailedCountAsync(user, cancellationToken);
+ await UserManager.ResetAccessFailedCountAsync(user);
await SignInAsync(user, isPersistent);
return await LogResultAsync(SignInResult.Success, user);
}
// If the token is incorrect, record the failure which also may cause the user to be locked out
- await UserManager.AccessFailedAsync(user, cancellationToken);
+ await UserManager.AccessFailedAsync(user);
return await LogResultAsync(SignInResult.Failed, user);
}
@@ -294,32 +285,30 @@ namespace Microsoft.AspNet.Identity
///
///
///
- public virtual async Task GetTwoFactorAuthenticationUserAsync(
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task GetTwoFactorAuthenticationUserAsync()
{
- var info = await RetrieveTwoFactorInfoAsync(cancellationToken);
+ var info = await RetrieveTwoFactorInfoAsync();
if (info == null)
{
return null;
}
- return await UserManager.FindByIdAsync(info.UserId, cancellationToken);
+ return await UserManager.FindByIdAsync(info.UserId);
}
- public virtual async Task ExternalLoginSignInAsync(string loginProvider, string providerKey, bool isPersistent,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task ExternalLoginSignInAsync(string loginProvider, string providerKey, bool isPersistent)
{
- var user = await UserManager.FindByLoginAsync(loginProvider, providerKey, cancellationToken);
+ var user = await UserManager.FindByLoginAsync(loginProvider, providerKey);
if (user == null)
{
return SignInResult.Failed;
}
- var error = await PreSignInCheck(user, cancellationToken);
+ var error = await PreSignInCheck(user);
if (error != null)
{
return await LogResultAsync(error, user);
}
- return await LogResultAsync(await SignInOrTwoFactorAsync(user, isPersistent, cancellationToken, loginProvider), user);
+ return await LogResultAsync(await SignInOrTwoFactorAsync(user, isPersistent, loginProvider), user);
}
private const string LoginProviderKey = "LoginProvider";
@@ -330,8 +319,7 @@ namespace Microsoft.AspNet.Identity
return Context.GetAuthenticationTypes().Where(d => !string.IsNullOrEmpty(d.Caption));
}
- public virtual async Task GetExternalLoginInfoAsync(string expectedXsrf = null,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task GetExternalLoginInfoAsync(string expectedXsrf = null)
{
var auth = await Context.AuthenticateAsync(IdentityOptions.ExternalCookieAuthenticationType);
if (auth == null || auth.Identity == null || auth.Properties.Dictionary == null || !auth.Properties.Dictionary.ContainsKey(LoginProviderKey))
@@ -372,17 +360,16 @@ namespace Microsoft.AspNet.Identity
return properties;
}
- private async Task SignInOrTwoFactorAsync(TUser user, bool isPersistent,
- CancellationToken cancellationToken, string loginProvider = null)
+ private async Task SignInOrTwoFactorAsync(TUser user, bool isPersistent, string loginProvider = null)
{
if (UserManager.SupportsUserTwoFactor &&
- await UserManager.GetTwoFactorEnabledAsync(user, cancellationToken) &&
- (await UserManager.GetValidTwoFactorProvidersAsync(user, cancellationToken)).Count > 0)
+ await UserManager.GetTwoFactorEnabledAsync(user) &&
+ (await UserManager.GetValidTwoFactorProvidersAsync(user)).Count > 0)
{
- if (!await IsTwoFactorClientRememberedAsync(user, cancellationToken))
+ if (!await IsTwoFactorClientRememberedAsync(user))
{
// Store the userId for use after two factor check
- var userId = await UserManager.GetUserIdAsync(user, cancellationToken);
+ var userId = await UserManager.GetUserIdAsync(user);
Context.Response.SignIn(StoreTwoFactorInfo(userId, loginProvider));
return SignInResult.TwoFactorRequired;
}
@@ -392,11 +379,11 @@ namespace Microsoft.AspNet.Identity
{
Context.Response.SignOut(IdentityOptions.ExternalCookieAuthenticationType);
}
- await SignInAsync(user, isPersistent, loginProvider, cancellationToken);
+ await SignInAsync(user, isPersistent, loginProvider);
return SignInResult.Success;
}
- private async Task RetrieveTwoFactorInfoAsync(CancellationToken cancellationToken)
+ private async Task RetrieveTwoFactorInfoAsync()
{
var result = await Context.AuthenticateAsync(IdentityOptions.TwoFactorUserIdCookieAuthenticationType);
if (result != null && result.Identity != null)
diff --git a/src/Microsoft.AspNet.Identity/TotpSecurityStampBasedTokenProvider.cs b/src/Microsoft.AspNet.Identity/TotpSecurityStampBasedTokenProvider.cs
index 57a7519cd2..721f371efc 100644
--- a/src/Microsoft.AspNet.Identity/TotpSecurityStampBasedTokenProvider.cs
+++ b/src/Microsoft.AspNet.Identity/TotpSecurityStampBasedTokenProvider.cs
@@ -22,8 +22,7 @@ namespace Microsoft.AspNet.Identity
///
///
///
- public virtual Task NotifyAsync(string token, UserManager manager, TUser user,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual Task NotifyAsync(string token, UserManager manager, TUser user)
{
return Task.FromResult(0);
}
@@ -35,14 +34,13 @@ namespace Microsoft.AspNet.Identity
///
///
///
- public virtual async Task GenerateAsync(string purpose, UserManager manager, TUser user,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task GenerateAsync(string purpose, UserManager manager, TUser user)
{
if (manager == null)
{
throw new ArgumentNullException("manager");
}
- var token = await manager.CreateSecurityTokenAsync(user, cancellationToken);
+ var token = await manager.CreateSecurityTokenAsync(user);
var modifier = await GetUserModifierAsync(purpose, manager, user);
return Rfc6238AuthenticationService.GenerateCode(token, modifier).ToString("D6", CultureInfo.InvariantCulture);
}
@@ -55,8 +53,7 @@ namespace Microsoft.AspNet.Identity
///
///
///
- public virtual async Task ValidateAsync(string purpose, string token, UserManager manager,
- TUser user, CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task ValidateAsync(string purpose, string token, UserManager manager, TUser user)
{
if (manager == null)
{
@@ -67,7 +64,7 @@ namespace Microsoft.AspNet.Identity
{
return false;
}
- var securityToken = await manager.CreateSecurityTokenAsync(user, cancellationToken);
+ var securityToken = await manager.CreateSecurityTokenAsync(user);
var modifier = await GetUserModifierAsync(purpose, manager, user);
return securityToken != null && Rfc6238AuthenticationService.ValidateCode(securityToken, code, modifier);
}
@@ -79,8 +76,7 @@ namespace Microsoft.AspNet.Identity
///
///
///
- public virtual async Task GetUserModifierAsync(string purpose, UserManager manager, TUser user,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task GetUserModifierAsync(string purpose, UserManager manager, TUser user)
{
if (manager == null)
{
@@ -90,6 +86,6 @@ namespace Microsoft.AspNet.Identity
return "Totp:" + purpose + ":" + userId;
}
- public abstract Task CanGenerateTwoFactorTokenAsync(UserManager manager, TUser user, CancellationToken cancellationToken = default(CancellationToken));
+ public abstract Task CanGenerateTwoFactorTokenAsync(UserManager manager, TUser user);
}
}
\ No newline at end of file
diff --git a/src/Microsoft.AspNet.Identity/UserManager.cs b/src/Microsoft.AspNet.Identity/UserManager.cs
index 775c828710..a914603c72 100644
--- a/src/Microsoft.AspNet.Identity/UserManager.cs
+++ b/src/Microsoft.AspNet.Identity/UserManager.cs
@@ -9,6 +9,8 @@ using System.Security.Claims;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
+using Microsoft.AspNet.Hosting;
+using Microsoft.AspNet.Http;
using Microsoft.Framework.Logging;
using Microsoft.Framework.OptionsModel;
@@ -29,6 +31,7 @@ namespace Microsoft.AspNet.Identity
private bool _disposed;
private IPasswordHasher _passwordHasher;
private IdentityOptions _options;
+ private HttpContext _context;
///
/// Constructor
@@ -52,7 +55,8 @@ namespace Microsoft.AspNet.Identity
IdentityErrorDescriber errors = null,
IEnumerable> tokenProviders = null,
IEnumerable msgProviders = null,
- ILogger> logger = null)
+ ILogger> logger = null,
+ IHttpContextAccessor contextAccessor = null)
{
if (store == null)
{
@@ -63,6 +67,7 @@ namespace Microsoft.AspNet.Identity
PasswordHasher = passwordHasher ?? new PasswordHasher();
KeyNormalizer = keyNormalizer ?? new UpperInvariantLookupNormalizer();
ErrorDescriber = errors ?? new IdentityErrorDescriber();
+ _context = contextAccessor?.Value;
if (userValidators != null)
{
@@ -304,6 +309,14 @@ namespace Microsoft.AspNet.Identity
}
}
+ private CancellationToken CancellationToken
+ {
+ get
+ {
+ return _context?.RequestAborted ?? CancellationToken.None;
+ }
+ }
+
///
/// Dispose the store context
///
@@ -313,12 +326,12 @@ namespace Microsoft.AspNet.Identity
GC.SuppressFinalize(this);
}
- private async Task ValidateUserInternal(TUser user, CancellationToken cancellationToken)
+ private async Task ValidateUserInternal(TUser user)
{
var errors = new List();
foreach (var v in UserValidators)
{
- var result = await v.ValidateAsync(this, user, cancellationToken);
+ var result = await v.ValidateAsync(this, user);
if (!result.Succeeded)
{
errors.AddRange(result.Errors);
@@ -327,12 +340,12 @@ namespace Microsoft.AspNet.Identity
return errors.Count > 0 ? IdentityResult.Failed(errors.ToArray()) : IdentityResult.Success;
}
- private async Task ValidatePasswordInternal(TUser user, string password, CancellationToken cancellationToken)
+ private async Task ValidatePasswordInternal(TUser user, string password)
{
var errors = new List();
foreach (var v in PasswordValidators)
{
- var result = await v.ValidateAsync(this, user, password, cancellationToken);
+ var result = await v.ValidateAsync(this, user, password);
if (!result.Succeeded)
{
errors.AddRange(result.Errors);
@@ -341,8 +354,7 @@ namespace Microsoft.AspNet.Identity
return errors.Count > 0 ? IdentityResult.Failed(errors.ToArray()) : IdentityResult.Success;
}
- public virtual Task GenerateConcurrencyStampAsync(TUser user,
- CancellationToken token = default(CancellationToken))
+ public virtual Task GenerateConcurrencyStampAsync(TUser user)
{
return Task.FromResult(Guid.NewGuid().ToString());
}
@@ -351,101 +363,90 @@ namespace Microsoft.AspNet.Identity
/// Validate user and update. Called by other UserManager methods
///
///
- ///
///
- private async Task UpdateUserAsync(TUser user,
- CancellationToken cancellationToken = default(CancellationToken))
+ private async Task UpdateUserAsync(TUser user)
{
- var result = await ValidateUserInternal(user, cancellationToken);
+ var result = await ValidateUserInternal(user);
if (!result.Succeeded)
{
return result;
}
- await UpdateNormalizedUserNameAsync(user, cancellationToken);
- await UpdateNormalizedEmailAsync(user, cancellationToken);
- return await Store.UpdateAsync(user, cancellationToken);
+ await UpdateNormalizedUserNameAsync(user);
+ await UpdateNormalizedEmailAsync(user);
+ return await Store.UpdateAsync(user, CancellationToken);
}
///
/// Create a user with no password
///
///
- ///
///
- public virtual async Task CreateAsync(TUser user,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task CreateAsync(TUser user)
{
ThrowIfDisposed();
- await UpdateSecurityStampInternal(user, cancellationToken);
- var result = await ValidateUserInternal(user, cancellationToken);
+ await UpdateSecurityStampInternal(user);
+ var result = await ValidateUserInternal(user);
if (!result.Succeeded)
{
return result;
}
if (Options.Lockout.EnabledByDefault && SupportsUserLockout)
{
- await GetUserLockoutStore().SetLockoutEnabledAsync(user, true, cancellationToken);
+ await GetUserLockoutStore().SetLockoutEnabledAsync(user, true, CancellationToken);
}
- await UpdateNormalizedUserNameAsync(user, cancellationToken);
- await UpdateNormalizedEmailAsync(user, cancellationToken);
- return await LogResultAsync(await Store.CreateAsync(user, cancellationToken), user);
+ await UpdateNormalizedUserNameAsync(user);
+ await UpdateNormalizedEmailAsync(user);
+ return await LogResultAsync(await Store.CreateAsync(user, CancellationToken), user);
}
///
/// Update a user
///
///
- ///
///
- public virtual async Task UpdateAsync(TUser user,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task UpdateAsync(TUser user)
{
ThrowIfDisposed();
if (user == null)
{
throw new ArgumentNullException("user");
}
- return await LogResultAsync(await UpdateUserAsync(user, cancellationToken), user);
+ return await LogResultAsync(await UpdateUserAsync(user), user);
}
///
/// Delete a user
///
///
- ///
///
- public virtual async Task DeleteAsync(TUser user,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task DeleteAsync(TUser user)
{
ThrowIfDisposed();
if (user == null)
{
throw new ArgumentNullException("user");
}
- return await LogResultAsync(await Store.DeleteAsync(user, cancellationToken), user);
+ return await LogResultAsync(await Store.DeleteAsync(user, CancellationToken), user);
}
///
/// Find a user by id
///
///
- ///
+
///
- public virtual Task FindByIdAsync(string userId,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual Task FindByIdAsync(string userId)
{
ThrowIfDisposed();
- return Store.FindByIdAsync(userId, cancellationToken);
+ return Store.FindByIdAsync(userId, CancellationToken);
}
///
/// Find a user by name
///
///
- ///
///
- public virtual Task FindByNameAsync(string userName,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual Task FindByNameAsync(string userName)
{
ThrowIfDisposed();
if (userName == null)
@@ -453,7 +454,7 @@ namespace Microsoft.AspNet.Identity
throw new ArgumentNullException("userName");
}
userName = NormalizeKey(userName);
- return Store.FindByNameAsync(userName, cancellationToken);
+ return Store.FindByNameAsync(userName, CancellationToken);
}
// IUserPasswordStore methods
@@ -472,10 +473,8 @@ namespace Microsoft.AspNet.Identity
///
///
///
- ///
///
- public virtual async Task CreateAsync(TUser user, string password,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task CreateAsync(TUser user, string password)
{
ThrowIfDisposed();
var passwordStore = GetPasswordStore();
@@ -487,12 +486,12 @@ namespace Microsoft.AspNet.Identity
{
throw new ArgumentNullException("password");
}
- var result = await UpdatePasswordHash(passwordStore, user, password, cancellationToken);
+ var result = await UpdatePasswordHash(passwordStore, user, password);
if (!result.Succeeded)
{
return result;
}
- return await CreateAsync(user, cancellationToken);
+ return await CreateAsync(user);
}
///
@@ -509,30 +508,26 @@ namespace Microsoft.AspNet.Identity
/// Update the user's normalized user name
///
///
- ///
///
- public virtual async Task UpdateNormalizedUserNameAsync(TUser user,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task UpdateNormalizedUserNameAsync(TUser user)
{
- var normalizedName = NormalizeKey(await GetUserNameAsync(user, cancellationToken));
- await Store.SetNormalizedUserNameAsync(user, normalizedName, cancellationToken);
+ var normalizedName = NormalizeKey(await GetUserNameAsync(user));
+ await Store.SetNormalizedUserNameAsync(user, normalizedName, CancellationToken);
}
///
/// Get the user's name
///
///
- ///
///
- public virtual async Task GetUserNameAsync(TUser user,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task GetUserNameAsync(TUser user)
{
ThrowIfDisposed();
if (user == null)
{
throw new ArgumentNullException("user");
}
- return await Store.GetUserNameAsync(user, cancellationToken);
+ return await Store.GetUserNameAsync(user, CancellationToken);
}
///
@@ -540,37 +535,33 @@ namespace Microsoft.AspNet.Identity
///
///
///
- ///
///
- public virtual async Task SetUserNameAsync(TUser user, string userName,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task SetUserNameAsync(TUser user, string userName)
{
ThrowIfDisposed();
if (user == null)
{
throw new ArgumentNullException("user");
}
- await UpdateUserName(user, userName, cancellationToken);
- return await LogResultAsync(await UpdateUserAsync(user, cancellationToken), user);
+ await UpdateUserName(user, userName);
+ return await LogResultAsync(await UpdateUserAsync(user), user);
}
- private async Task UpdateUserName(TUser user, string userName, CancellationToken cancellationToken)
+ private async Task UpdateUserName(TUser user, string userName)
{
- await Store.SetUserNameAsync(user, userName, cancellationToken);
- await UpdateNormalizedUserNameAsync(user, cancellationToken);
+ await Store.SetUserNameAsync(user, userName, CancellationToken);
+ await UpdateNormalizedUserNameAsync(user);
}
///
/// Get the user's id
///
///
- ///
///
- public virtual async Task GetUserIdAsync(TUser user,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task GetUserIdAsync(TUser user)
{
ThrowIfDisposed();
- return await Store.GetUserIdAsync(user, cancellationToken);
+ return await Store.GetUserIdAsync(user, CancellationToken);
}
///
@@ -578,10 +569,8 @@ namespace Microsoft.AspNet.Identity
///
///
///
- ///
///
- public virtual async Task CheckPasswordAsync(TUser user, string password,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task CheckPasswordAsync(TUser user, string password)
{
ThrowIfDisposed();
var passwordStore = GetPasswordStore();
@@ -589,11 +578,11 @@ namespace Microsoft.AspNet.Identity
{
return false;
}
- var result = await VerifyPasswordAsync(passwordStore, user, password, cancellationToken);
+ var result = await VerifyPasswordAsync(passwordStore, user, password);
if (result == PasswordVerificationResult.SuccessRehashNeeded)
{
- await UpdatePasswordHash(passwordStore, user, password, cancellationToken, validatePassword: false);
- await UpdateUserAsync(user, cancellationToken);
+ await UpdatePasswordHash(passwordStore, user, password, validatePassword: false);
+ await UpdateUserAsync(user);
}
return await LogResultAsync(result != PasswordVerificationResult.Failed, user);
@@ -603,10 +592,8 @@ namespace Microsoft.AspNet.Identity
/// Returns true if the user has a password
///
///
- ///
///
- public virtual async Task HasPasswordAsync(TUser user,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task HasPasswordAsync(TUser user)
{
ThrowIfDisposed();
var passwordStore = GetPasswordStore();
@@ -614,7 +601,7 @@ namespace Microsoft.AspNet.Identity
{
throw new ArgumentNullException("user");
}
- return await LogResultAsync(await passwordStore.HasPasswordAsync(user, cancellationToken), user);
+ return await LogResultAsync(await passwordStore.HasPasswordAsync(user, CancellationToken), user);
}
///
@@ -622,10 +609,8 @@ namespace Microsoft.AspNet.Identity
///
///
///
- ///
///
- public virtual async Task AddPasswordAsync(TUser user, string password,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task AddPasswordAsync(TUser user, string password)
{
ThrowIfDisposed();
var passwordStore = GetPasswordStore();
@@ -633,17 +618,17 @@ namespace Microsoft.AspNet.Identity
{
throw new ArgumentNullException("user");
}
- var hash = await passwordStore.GetPasswordHashAsync(user, cancellationToken);
+ var hash = await passwordStore.GetPasswordHashAsync(user, CancellationToken);
if (hash != null)
{
return await LogResultAsync(IdentityResult.Failed(ErrorDescriber.UserAlreadyHasPassword()), user);
}
- var result = await UpdatePasswordHash(passwordStore, user, password, cancellationToken);
+ var result = await UpdatePasswordHash(passwordStore, user, password);
if (!result.Succeeded)
{
return await LogResultAsync(result, user);
}
- return await LogResultAsync(await UpdateUserAsync(user, cancellationToken), user);
+ return await LogResultAsync(await UpdateUserAsync(user), user);
}
///
@@ -652,10 +637,8 @@ namespace Microsoft.AspNet.Identity
///
///
///
- ///
///
- public virtual async Task ChangePasswordAsync(TUser user, string currentPassword,
- string newPassword, CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task ChangePasswordAsync(TUser user, string currentPassword, string newPassword)
{
ThrowIfDisposed();
var passwordStore = GetPasswordStore();
@@ -663,14 +646,14 @@ namespace Microsoft.AspNet.Identity
{
throw new ArgumentNullException("user");
}
- if (await VerifyPasswordAsync(passwordStore, user, currentPassword, cancellationToken) != PasswordVerificationResult.Failed)
+ if (await VerifyPasswordAsync(passwordStore, user, currentPassword) != PasswordVerificationResult.Failed)
{
- var result = await UpdatePasswordHash(passwordStore, user, newPassword, cancellationToken);
+ var result = await UpdatePasswordHash(passwordStore, user, newPassword);
if (!result.Succeeded)
{
return await LogResultAsync(result, user);
}
- return await LogResultAsync(await UpdateUserAsync(user, cancellationToken), user);
+ return await LogResultAsync(await UpdateUserAsync(user), user);
}
return await LogResultAsync(IdentityResult.Failed(ErrorDescriber.PasswordMismatch()), user);
}
@@ -679,7 +662,7 @@ namespace Microsoft.AspNet.Identity
/// Remove a user's password
///
///
- ///
+
///
public virtual async Task RemovePasswordAsync(TUser user,
CancellationToken cancellationToken = default(CancellationToken))
@@ -690,25 +673,24 @@ namespace Microsoft.AspNet.Identity
{
throw new ArgumentNullException("user");
}
- await UpdatePasswordHash(passwordStore, user, null, cancellationToken, validatePassword: false);
- return await LogResultAsync(await UpdateUserAsync(user, cancellationToken), user);
+ await UpdatePasswordHash(passwordStore, user, null, validatePassword: false);
+ return await LogResultAsync(await UpdateUserAsync(user), user);
}
internal async Task UpdatePasswordHash(IUserPasswordStore passwordStore,
- TUser user, string newPassword, CancellationToken cancellationToken, bool validatePassword = true)
+ TUser user, string newPassword, bool validatePassword = true)
{
if (validatePassword)
{
- var validate = await ValidatePasswordInternal(user, newPassword, cancellationToken);
+ var validate = await ValidatePasswordInternal(user, newPassword);
if (!validate.Succeeded)
{
return validate;
}
}
var hash = newPassword != null ? PasswordHasher.HashPassword(user, newPassword) : null;
- await
- passwordStore.SetPasswordHashAsync(user, hash, cancellationToken);
- await UpdateSecurityStampInternal(user, cancellationToken);
+ await passwordStore.SetPasswordHashAsync(user, hash, CancellationToken);
+ await UpdateSecurityStampInternal(user);
return IdentityResult.Success;
}
@@ -718,12 +700,10 @@ namespace Microsoft.AspNet.Identity
///
///
///
- ///
///
- protected virtual async Task VerifyPasswordAsync(IUserPasswordStore store, TUser user,
- string password, CancellationToken cancellationToken = default(CancellationToken))
+ protected virtual async Task VerifyPasswordAsync(IUserPasswordStore store, TUser user, string password)
{
- var hash = await store.GetPasswordHashAsync(user, cancellationToken);
+ var hash = await store.GetPasswordHashAsync(user, CancellationToken);
return PasswordHasher.VerifyHashedPassword(user, hash, password);
}
@@ -742,10 +722,8 @@ namespace Microsoft.AspNet.Identity
/// Returns the current security stamp for a user
///
///
- ///
///
- public virtual async Task GetSecurityStampAsync(TUser user,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task GetSecurityStampAsync(TUser user)
{
ThrowIfDisposed();
var securityStore = GetSecurityStore();
@@ -753,17 +731,15 @@ namespace Microsoft.AspNet.Identity
{
throw new ArgumentNullException("user");
}
- return await securityStore.GetSecurityStampAsync(user, cancellationToken);
+ return await securityStore.GetSecurityStampAsync(user, CancellationToken);
}
///
/// Generate a new security stamp for a user, used for SignOutEverywhere functionality
///
///
- ///
///
- public virtual async Task UpdateSecurityStampAsync(TUser user,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task UpdateSecurityStampAsync(TUser user)
{
ThrowIfDisposed();
GetSecurityStore();
@@ -771,23 +747,20 @@ namespace Microsoft.AspNet.Identity
{
throw new ArgumentNullException("user");
}
- await UpdateSecurityStampInternal(user, cancellationToken);
- return await LogResultAsync(await UpdateUserAsync(user, cancellationToken), user);
+ await UpdateSecurityStampInternal(user);
+ return await LogResultAsync(await UpdateUserAsync(user), user);
}
///
/// GenerateAsync a password reset token for the user using the UserTokenProvider
///
///
- ///
///
- public virtual async Task GeneratePasswordResetTokenAsync(TUser user,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task GeneratePasswordResetTokenAsync(TUser user)
{
ThrowIfDisposed();
- var token = await GenerateUserTokenAsync(user, Options.PasswordResetTokenProvider, "ResetPassword", cancellationToken);
+ var token = await GenerateUserTokenAsync(user, Options.PasswordResetTokenProvider, "ResetPassword");
await LogResultAsync(IdentityResult.Success, user);
-
return token;
}
@@ -797,10 +770,8 @@ namespace Microsoft.AspNet.Identity
///
///
///
- ///
///
- public virtual async Task ResetPasswordAsync(TUser user, string token, string newPassword,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task ResetPasswordAsync(TUser user, string token, string newPassword)
{
ThrowIfDisposed();
if (user == null)
@@ -808,25 +779,25 @@ namespace Microsoft.AspNet.Identity
throw new ArgumentNullException("user");
}
// Make sure the token is valid and the stamp matches
- if (!await VerifyUserTokenAsync(user, Options.PasswordResetTokenProvider, "ResetPassword", token, cancellationToken))
+ if (!await VerifyUserTokenAsync(user, Options.PasswordResetTokenProvider, "ResetPassword", token))
{
return await LogResultAsync(IdentityResult.Failed(ErrorDescriber.InvalidToken()), user);
}
var passwordStore = GetPasswordStore();
- var result = await UpdatePasswordHash(passwordStore, user, newPassword, cancellationToken);
+ var result = await UpdatePasswordHash(passwordStore, user, newPassword);
if (!result.Succeeded)
{
return await LogResultAsync(result, user);
}
- return await LogResultAsync(await UpdateUserAsync(user, cancellationToken), user);
+ return await LogResultAsync(await UpdateUserAsync(user), user);
}
// Update the security stamp if the store supports it
- internal async Task UpdateSecurityStampInternal(TUser user, CancellationToken cancellationToken)
+ internal async Task UpdateSecurityStampInternal(TUser user)
{
if (SupportsUserSecurityStamp)
{
- await GetSecurityStore().SetSecurityStampAsync(user, NewSecurityStamp(), cancellationToken);
+ await GetSecurityStore().SetSecurityStampAsync(user, NewSecurityStamp(), CancellationToken);
}
}
@@ -851,10 +822,8 @@ namespace Microsoft.AspNet.Identity
///
///
///
- ///
///
- public virtual Task FindByLoginAsync(string loginProvider, string providerKey,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual Task FindByLoginAsync(string loginProvider, string providerKey)
{
ThrowIfDisposed();
var loginStore = GetLoginStore();
@@ -866,7 +835,7 @@ namespace Microsoft.AspNet.Identity
{
throw new ArgumentNullException("providerKey");
}
- return loginStore.FindByLoginAsync(loginProvider, providerKey, cancellationToken);
+ return loginStore.FindByLoginAsync(loginProvider, providerKey, CancellationToken);
}
///
@@ -874,10 +843,8 @@ namespace Microsoft.AspNet.Identity
///
///
///
- ///
///
- public virtual async Task RemoveLoginAsync(TUser user, string loginProvider, string providerKey,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task RemoveLoginAsync(TUser user, string loginProvider, string providerKey)
{
ThrowIfDisposed();
var loginStore = GetLoginStore();
@@ -893,9 +860,9 @@ namespace Microsoft.AspNet.Identity
{
throw new ArgumentNullException("user");
}
- await loginStore.RemoveLoginAsync(user, loginProvider, providerKey, cancellationToken);
- await UpdateSecurityStampInternal(user, cancellationToken);
- return await LogResultAsync(await UpdateUserAsync(user, cancellationToken), user);
+ await loginStore.RemoveLoginAsync(user, loginProvider, providerKey, CancellationToken);
+ await UpdateSecurityStampInternal(user);
+ return await LogResultAsync(await UpdateUserAsync(user), user);
}
///
@@ -903,10 +870,8 @@ namespace Microsoft.AspNet.Identity
///
///
///
- ///
///
- public virtual async Task AddLoginAsync(TUser user, UserLoginInfo login,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task AddLoginAsync(TUser user, UserLoginInfo login)
{
ThrowIfDisposed();
var loginStore = GetLoginStore();
@@ -918,23 +883,21 @@ namespace Microsoft.AspNet.Identity
{
throw new ArgumentNullException("user");
}
- var existingUser = await FindByLoginAsync(login.LoginProvider, login.ProviderKey, cancellationToken);
+ var existingUser = await FindByLoginAsync(login.LoginProvider, login.ProviderKey);
if (existingUser != null)
{
return await LogResultAsync(IdentityResult.Failed(ErrorDescriber.LoginAlreadyAssociated()), user);
}
- await loginStore.AddLoginAsync(user, login, cancellationToken);
- return await LogResultAsync(await UpdateUserAsync(user, cancellationToken), user);
+ await loginStore.AddLoginAsync(user, login, CancellationToken);
+ return await LogResultAsync(await UpdateUserAsync(user), user);
}
///
/// Gets the logins for a user.
///
///
- ///
///
- public virtual async Task> GetLoginsAsync(TUser user,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task> GetLoginsAsync(TUser user)
{
ThrowIfDisposed();
var loginStore = GetLoginStore();
@@ -942,7 +905,7 @@ namespace Microsoft.AspNet.Identity
{
throw new ArgumentNullException("user");
}
- return await loginStore.GetLoginsAsync(user, cancellationToken);
+ return await loginStore.GetLoginsAsync(user, CancellationToken);
}
// IUserClaimStore methods
@@ -961,10 +924,8 @@ namespace Microsoft.AspNet.Identity
///
///
///
- ///
///
- public virtual Task AddClaimAsync(TUser user, Claim claim,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual Task AddClaimAsync(TUser user, Claim claim)
{
ThrowIfDisposed();
var claimStore = GetClaimStore();
@@ -976,18 +937,16 @@ namespace Microsoft.AspNet.Identity
{
throw new ArgumentNullException("user");
}
- return AddClaimsAsync(user, new Claim[] { claim }, cancellationToken);
+ return AddClaimsAsync(user, new Claim[] { claim });
}
///
- /// Add a user claim
+ /// Add claims for a user
///
///
- ///
- ///
+ ///
///
- public virtual async Task AddClaimsAsync(TUser user, IEnumerable claims,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task AddClaimsAsync(TUser user, IEnumerable claims)
{
ThrowIfDisposed();
var claimStore = GetClaimStore();
@@ -999,8 +958,8 @@ namespace Microsoft.AspNet.Identity
{
throw new ArgumentNullException("user");
}
- await claimStore.AddClaimsAsync(user, claims, cancellationToken);
- return await LogResultAsync(await UpdateUserAsync(user, cancellationToken), user);
+ await claimStore.AddClaimsAsync(user, claims, CancellationToken);
+ return await LogResultAsync(await UpdateUserAsync(user), user);
}
///
@@ -1009,10 +968,8 @@ namespace Microsoft.AspNet.Identity
///
///
///
- ///
///
- public virtual async Task ReplaceClaimAsync(TUser user, Claim claim, Claim newClaim,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task ReplaceClaimAsync(TUser user, Claim claim, Claim newClaim)
{
ThrowIfDisposed();
var claimStore = GetClaimStore();
@@ -1028,8 +985,8 @@ namespace Microsoft.AspNet.Identity
{
throw new ArgumentNullException("user");
}
- await claimStore.ReplaceClaimAsync(user, claim, newClaim, cancellationToken);
- return await LogResultAsync(await UpdateUserAsync(user, cancellationToken), user);
+ await claimStore.ReplaceClaimAsync(user, claim, newClaim, CancellationToken);
+ return await LogResultAsync(await UpdateUserAsync(user), user);
}
///
@@ -1037,10 +994,8 @@ namespace Microsoft.AspNet.Identity
///
///
///
- ///
///
- public virtual Task RemoveClaimAsync(TUser user, Claim claim,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual Task RemoveClaimAsync(TUser user, Claim claim)
{
ThrowIfDisposed();
var claimStore = GetClaimStore();
@@ -1052,7 +1007,7 @@ namespace Microsoft.AspNet.Identity
{
throw new ArgumentNullException("claim");
}
- return RemoveClaimsAsync(user, new Claim[] { claim }, cancellationToken);
+ return RemoveClaimsAsync(user, new Claim[] { claim });
}
///
@@ -1060,10 +1015,8 @@ namespace Microsoft.AspNet.Identity
///
///
///
- ///
///
- public virtual async Task RemoveClaimsAsync(TUser user, IEnumerable claims,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task RemoveClaimsAsync(TUser user, IEnumerable claims)
{
ThrowIfDisposed();
var claimStore = GetClaimStore();
@@ -1075,18 +1028,16 @@ namespace Microsoft.AspNet.Identity
{
throw new ArgumentNullException("claims");
}
- await claimStore.RemoveClaimsAsync(user, claims, cancellationToken);
- return await LogResultAsync(await UpdateUserAsync(user, cancellationToken), user);
+ await claimStore.RemoveClaimsAsync(user, claims, CancellationToken);
+ return await LogResultAsync(await UpdateUserAsync(user), user);
}
///
/// Get a users's claims
///
///
- ///
///
- public virtual async Task> GetClaimsAsync(TUser user,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task> GetClaimsAsync(TUser user)
{
ThrowIfDisposed();
var claimStore = GetClaimStore();
@@ -1094,7 +1045,7 @@ namespace Microsoft.AspNet.Identity
{
throw new ArgumentNullException("user");
}
- return await claimStore.GetClaimsAsync(user, cancellationToken);
+ return await claimStore.GetClaimsAsync(user, CancellationToken);
}
private IUserRoleStore GetUserRoleStore()
@@ -1112,10 +1063,8 @@ namespace Microsoft.AspNet.Identity
///
///
///
- ///
///
- public virtual async Task AddToRoleAsync(TUser user, string role,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task AddToRoleAsync(TUser user, string role)
{
ThrowIfDisposed();
var userRoleStore = GetUserRoleStore();
@@ -1123,13 +1072,13 @@ namespace Microsoft.AspNet.Identity
{
throw new ArgumentNullException("user");
}
- var userRoles = await userRoleStore.GetRolesAsync(user, cancellationToken);
+ var userRoles = await userRoleStore.GetRolesAsync(user, CancellationToken);
if (userRoles.Contains(role))
{
return await LogResultAsync(IdentityResult.Failed(ErrorDescriber.UserAlreadyInRole(role)), user);
}
- await userRoleStore.AddToRoleAsync(user, role, cancellationToken);
- return await LogResultAsync(await UpdateUserAsync(user, cancellationToken), user);
+ await userRoleStore.AddToRoleAsync(user, role, CancellationToken);
+ return await LogResultAsync(await UpdateUserAsync(user), user);
}
///
@@ -1137,10 +1086,8 @@ namespace Microsoft.AspNet.Identity
///
///
///
- ///
///
- public virtual async Task AddToRolesAsync(TUser user, IEnumerable roles,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task AddToRolesAsync(TUser user, IEnumerable roles)
{
ThrowIfDisposed();
var userRoleStore = GetUserRoleStore();
@@ -1152,16 +1099,16 @@ namespace Microsoft.AspNet.Identity
{
throw new ArgumentNullException("roles");
}
- var userRoles = await userRoleStore.GetRolesAsync(user, cancellationToken);
+ var userRoles = await userRoleStore.GetRolesAsync(user, CancellationToken);
foreach (var role in roles)
{
if (userRoles.Contains(role))
{
return await LogResultAsync(IdentityResult.Failed(ErrorDescriber.UserAlreadyInRole(role)), user);
}
- await userRoleStore.AddToRoleAsync(user, role, cancellationToken);
+ await userRoleStore.AddToRoleAsync(user, role, CancellationToken);
}
- return await LogResultAsync(await UpdateUserAsync(user, cancellationToken), user);
+ return await LogResultAsync(await UpdateUserAsync(user), user);
}
///
@@ -1169,10 +1116,8 @@ namespace Microsoft.AspNet.Identity
///
///
///
- ///
///
- public virtual async Task RemoveFromRoleAsync(TUser user, string role,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task RemoveFromRoleAsync(TUser user, string role)
{
ThrowIfDisposed();
var userRoleStore = GetUserRoleStore();
@@ -1180,12 +1125,12 @@ namespace Microsoft.AspNet.Identity
{
throw new ArgumentNullException("user");
}
- if (!await userRoleStore.IsInRoleAsync(user, role, cancellationToken))
+ if (!await userRoleStore.IsInRoleAsync(user, role, CancellationToken))
{
return await LogResultAsync(IdentityResult.Failed(ErrorDescriber.UserNotInRole(role)), user);
}
- await userRoleStore.RemoveFromRoleAsync(user, role, cancellationToken);
- return await LogResultAsync(await UpdateUserAsync(user, cancellationToken), user);
+ await userRoleStore.RemoveFromRoleAsync(user, role, CancellationToken);
+ return await LogResultAsync(await UpdateUserAsync(user), user);
}
///
@@ -1193,10 +1138,8 @@ namespace Microsoft.AspNet.Identity
///
///
///
- ///
///
- public virtual async Task RemoveFromRolesAsync(TUser user, IEnumerable roles,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task RemoveFromRolesAsync(TUser user, IEnumerable roles)
{
ThrowIfDisposed();
var userRoleStore = GetUserRoleStore();
@@ -1210,23 +1153,21 @@ namespace Microsoft.AspNet.Identity
}
foreach (var role in roles)
{
- if (!await userRoleStore.IsInRoleAsync(user, role, cancellationToken))
+ if (!await userRoleStore.IsInRoleAsync(user, role, CancellationToken))
{
return await LogResultAsync(IdentityResult.Failed(ErrorDescriber.UserNotInRole(role)), user);
}
- await userRoleStore.RemoveFromRoleAsync(user, role, cancellationToken);
+ await userRoleStore.RemoveFromRoleAsync(user, role, CancellationToken);
}
- return await LogResultAsync(await UpdateUserAsync(user, cancellationToken), user);
+ return await LogResultAsync(await UpdateUserAsync(user), user);
}
///
/// Returns the roles for the user
///
///
- ///
///
- public virtual async Task> GetRolesAsync(TUser user,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task> GetRolesAsync(TUser user)
{
ThrowIfDisposed();
var userRoleStore = GetUserRoleStore();
@@ -1234,7 +1175,7 @@ namespace Microsoft.AspNet.Identity
{
throw new ArgumentNullException("user");
}
- return await userRoleStore.GetRolesAsync(user, cancellationToken);
+ return await userRoleStore.GetRolesAsync(user, CancellationToken);
}
///
@@ -1242,10 +1183,8 @@ namespace Microsoft.AspNet.Identity
///
///
///
- ///
///
- public virtual async Task IsInRoleAsync(TUser user, string role,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task IsInRoleAsync(TUser user, string role)
{
ThrowIfDisposed();
var userRoleStore = GetUserRoleStore();
@@ -1253,7 +1192,7 @@ namespace Microsoft.AspNet.Identity
{
throw new ArgumentNullException("user");
}
- return await userRoleStore.IsInRoleAsync(user, role, cancellationToken);
+ return await userRoleStore.IsInRoleAsync(user, role, CancellationToken);
}
// IUserEmailStore methods
@@ -1271,10 +1210,8 @@ namespace Microsoft.AspNet.Identity
/// Get a user's email
///
///
- ///
///
- public virtual async Task GetEmailAsync(TUser user,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task GetEmailAsync(TUser user)
{
ThrowIfDisposed();
var store = GetEmailStore();
@@ -1282,7 +1219,7 @@ namespace Microsoft.AspNet.Identity
{
throw new ArgumentNullException("user");
}
- return await store.GetEmailAsync(user, cancellationToken);
+ return await store.GetEmailAsync(user, CancellationToken);
}
///
@@ -1290,32 +1227,27 @@ namespace Microsoft.AspNet.Identity
///
///
///
- ///
///
- public virtual async Task SetEmailAsync(TUser user, string email,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task SetEmailAsync(TUser user, string email)
{
ThrowIfDisposed();
-
var store = GetEmailStore();
if (user == null)
{
throw new ArgumentNullException("user");
}
- await store.SetEmailAsync(user, email, cancellationToken);
- await store.SetEmailConfirmedAsync(user, false, cancellationToken);
- await UpdateSecurityStampInternal(user, cancellationToken);
- return await LogResultAsync(await UpdateUserAsync(user, cancellationToken), user);
+ await store.SetEmailAsync(user, email, CancellationToken);
+ await store.SetEmailConfirmedAsync(user, false, CancellationToken);
+ await UpdateSecurityStampInternal(user);
+ return await LogResultAsync(await UpdateUserAsync(user), user);
}
///
/// FindByLoginAsync a user by his email
///
///
- ///
///
- public virtual Task FindByEmailAsync(string email,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual Task FindByEmailAsync(string email)
{
ThrowIfDisposed();
var store = GetEmailStore();
@@ -1323,23 +1255,21 @@ namespace Microsoft.AspNet.Identity
{
throw new ArgumentNullException("email");
}
- return store.FindByEmailAsync(NormalizeKey(email), cancellationToken);
+ return store.FindByEmailAsync(NormalizeKey(email), CancellationToken);
}
///
/// Update the user's normalized email
///
///
- ///
///
- public virtual async Task UpdateNormalizedEmailAsync(TUser user,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task UpdateNormalizedEmailAsync(TUser user)
{
var store = GetEmailStore(throwOnFail: false);
if (store != null)
{
- var email = await GetEmailAsync(user, cancellationToken);
- await store.SetNormalizedEmailAsync(user, NormalizeKey(email), cancellationToken);
+ var email = await GetEmailAsync(user);
+ await store.SetNormalizedEmailAsync(user, NormalizeKey(email), CancellationToken);
}
}
@@ -1348,15 +1278,12 @@ namespace Microsoft.AspNet.Identity
/// Get the confirmation token for the user
///
///
- ///
///
- public async virtual Task GenerateEmailConfirmationTokenAsync(TUser user,
- CancellationToken cancellationToken = default(CancellationToken))
+ public async virtual Task GenerateEmailConfirmationTokenAsync(TUser user)
{
ThrowIfDisposed();
- var token = await GenerateUserTokenAsync(user, Options.EmailConfirmationTokenProvider, "Confirmation", cancellationToken);
+ var token = await GenerateUserTokenAsync(user, Options.EmailConfirmationTokenProvider, "Confirmation");
await LogResultAsync(IdentityResult.Success, user);
-
return token;
}
@@ -1365,10 +1292,8 @@ namespace Microsoft.AspNet.Identity
///
///
///
- ///
///
- public virtual async Task ConfirmEmailAsync(TUser user, string token,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task ConfirmEmailAsync(TUser user, string token)
{
ThrowIfDisposed();
var store = GetEmailStore();
@@ -1376,22 +1301,20 @@ namespace Microsoft.AspNet.Identity
{
throw new ArgumentNullException("user");
}
- if (!await VerifyUserTokenAsync(user, Options.EmailConfirmationTokenProvider, "Confirmation", token, cancellationToken))
+ if (!await VerifyUserTokenAsync(user, Options.EmailConfirmationTokenProvider, "Confirmation", token))
{
return await LogResultAsync(IdentityResult.Failed(ErrorDescriber.InvalidToken()), user);
}
- await store.SetEmailConfirmedAsync(user, true, cancellationToken);
- return await LogResultAsync(await UpdateUserAsync(user, cancellationToken), user);
+ await store.SetEmailConfirmedAsync(user, true, CancellationToken);
+ return await LogResultAsync(await UpdateUserAsync(user), user);
}
///
/// Returns true if the user's email has been confirmed
///
///
- ///
///
- public virtual async Task IsEmailConfirmedAsync(TUser user,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task IsEmailConfirmedAsync(TUser user)
{
ThrowIfDisposed();
var store = GetEmailStore();
@@ -1399,7 +1322,7 @@ namespace Microsoft.AspNet.Identity
{
throw new ArgumentNullException("user");
}
- return await store.GetEmailConfirmedAsync(user, cancellationToken);
+ return await store.GetEmailConfirmedAsync(user, CancellationToken);
}
private static string GetChangeEmailPurpose(string newEmail)
@@ -1411,15 +1334,12 @@ namespace Microsoft.AspNet.Identity
/// Generate a change email token for the user using the UserTokenProvider
///
///
- ///
///
- public virtual async Task GenerateChangeEmailTokenAsync(TUser user, string newEmail,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task GenerateChangeEmailTokenAsync(TUser user, string newEmail)
{
ThrowIfDisposed();
- var token = await GenerateUserTokenAsync(user, Options.ChangeEmailTokenProvider, GetChangeEmailPurpose(newEmail), cancellationToken);
+ var token = await GenerateUserTokenAsync(user, Options.ChangeEmailTokenProvider, GetChangeEmailPurpose(newEmail));
await LogResultAsync(IdentityResult.Success, user);
-
return token;
}
@@ -1429,10 +1349,8 @@ namespace Microsoft.AspNet.Identity
///
///
///
- ///
///
- public virtual async Task ChangeEmailAsync(TUser user, string newEmail, string token,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task ChangeEmailAsync(TUser user, string newEmail, string token)
{
ThrowIfDisposed();
if (user == null)
@@ -1440,15 +1358,15 @@ namespace Microsoft.AspNet.Identity
throw new ArgumentNullException("user");
}
// Make sure the token is valid and the stamp matches
- if (!await VerifyUserTokenAsync(user, Options.ChangeEmailTokenProvider, GetChangeEmailPurpose(newEmail), token, cancellationToken))
+ if (!await VerifyUserTokenAsync(user, Options.ChangeEmailTokenProvider, GetChangeEmailPurpose(newEmail), token))
{
return await LogResultAsync(IdentityResult.Failed(ErrorDescriber.InvalidToken()), user);
}
var store = GetEmailStore();
- await store.SetEmailAsync(user, newEmail, cancellationToken);
- await store.SetEmailConfirmedAsync(user, true, cancellationToken);
- await UpdateSecurityStampInternal(user, cancellationToken);
- return await LogResultAsync(await UpdateUserAsync(user, cancellationToken), user);
+ await store.SetEmailAsync(user, newEmail, CancellationToken);
+ await store.SetEmailConfirmedAsync(user, true, CancellationToken);
+ await UpdateSecurityStampInternal(user);
+ return await LogResultAsync(await UpdateUserAsync(user), user);
}
// IUserPhoneNumberStore methods
@@ -1466,10 +1384,8 @@ namespace Microsoft.AspNet.Identity
/// Get a user's phoneNumber
///
///
- ///
///
- public virtual async Task GetPhoneNumberAsync(TUser user,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task GetPhoneNumberAsync(TUser user)
{
ThrowIfDisposed();
var store = GetPhoneNumberStore();
@@ -1477,7 +1393,7 @@ namespace Microsoft.AspNet.Identity
{
throw new ArgumentNullException("user");
}
- return await store.GetPhoneNumberAsync(user, cancellationToken);
+ return await store.GetPhoneNumberAsync(user, CancellationToken);
}
///
@@ -1485,10 +1401,8 @@ namespace Microsoft.AspNet.Identity
///
///
///
- ///
///
- public virtual async Task SetPhoneNumberAsync(TUser user, string phoneNumber,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task SetPhoneNumberAsync(TUser user, string phoneNumber)
{
ThrowIfDisposed();
var store = GetPhoneNumberStore();
@@ -1496,10 +1410,10 @@ namespace Microsoft.AspNet.Identity
{
throw new ArgumentNullException("user");
}
- await store.SetPhoneNumberAsync(user, phoneNumber, cancellationToken);
- await store.SetPhoneNumberConfirmedAsync(user, false, cancellationToken);
- await UpdateSecurityStampInternal(user, cancellationToken);
- return await LogResultAsync(await UpdateUserAsync(user, cancellationToken), user);
+ await store.SetPhoneNumberAsync(user, phoneNumber, CancellationToken);
+ await store.SetPhoneNumberConfirmedAsync(user, false, CancellationToken);
+ await UpdateSecurityStampInternal(user);
+ return await LogResultAsync(await UpdateUserAsync(user), user);
}
///
@@ -1508,10 +1422,8 @@ namespace Microsoft.AspNet.Identity
///
///
///
- ///
///
- public virtual async Task ChangePhoneNumberAsync(TUser user, string phoneNumber, string token,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task ChangePhoneNumberAsync(TUser user, string phoneNumber, string token)
{
ThrowIfDisposed();
var store = GetPhoneNumberStore();
@@ -1519,24 +1431,22 @@ namespace Microsoft.AspNet.Identity
{
throw new ArgumentNullException("user");
}
- if (!await VerifyChangePhoneNumberTokenAsync(user, token, phoneNumber, cancellationToken))
+ if (!await VerifyChangePhoneNumberTokenAsync(user, token, phoneNumber))
{
return await LogResultAsync(IdentityResult.Failed(ErrorDescriber.InvalidToken()), user);
}
- await store.SetPhoneNumberAsync(user, phoneNumber, cancellationToken);
- await store.SetPhoneNumberConfirmedAsync(user, true, cancellationToken);
- await UpdateSecurityStampInternal(user, cancellationToken);
- return await LogResultAsync(await UpdateUserAsync(user, cancellationToken), user);
+ await store.SetPhoneNumberAsync(user, phoneNumber, CancellationToken);
+ await store.SetPhoneNumberConfirmedAsync(user, true, CancellationToken);
+ await UpdateSecurityStampInternal(user);
+ return await LogResultAsync(await UpdateUserAsync(user), user);
}
///
/// Returns true if the user's phone number has been confirmed
///
///
- ///
///
- public virtual async Task IsPhoneNumberConfirmedAsync(TUser user,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task IsPhoneNumberConfirmedAsync(TUser user)
{
ThrowIfDisposed();
var store = GetPhoneNumberStore();
@@ -1544,15 +1454,13 @@ namespace Microsoft.AspNet.Identity
{
throw new ArgumentNullException("user");
}
- return await store.GetPhoneNumberConfirmedAsync(user, cancellationToken);
+ return await store.GetPhoneNumberConfirmedAsync(user, CancellationToken);
}
// Two factor APIS
-
- internal async Task CreateSecurityTokenAsync(TUser user, CancellationToken cancellationToken)
+ internal async Task CreateSecurityTokenAsync(TUser user)
{
- return
- new SecurityToken(Encoding.Unicode.GetBytes(await GetSecurityStampAsync(user, cancellationToken)));
+ return new SecurityToken(Encoding.Unicode.GetBytes(await GetSecurityStampAsync(user)));
}
///
@@ -1561,14 +1469,12 @@ namespace Microsoft.AspNet.Identity
///
///
///
- public virtual async Task GenerateChangePhoneNumberTokenAsync(TUser user, string phoneNumber,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task GenerateChangePhoneNumberTokenAsync(TUser user, string phoneNumber)
{
ThrowIfDisposed();
var token = Rfc6238AuthenticationService.GenerateCode(
- await CreateSecurityTokenAsync(user, cancellationToken), phoneNumber)
+ await CreateSecurityTokenAsync(user), phoneNumber)
.ToString(CultureInfo.InvariantCulture);
-
await LogResultAsync(IdentityResult.Success, user);
return token;
}
@@ -1580,11 +1486,10 @@ namespace Microsoft.AspNet.Identity
///
///
///
- public virtual async Task VerifyChangePhoneNumberTokenAsync(TUser user, string token, string phoneNumber,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task VerifyChangePhoneNumberTokenAsync(TUser user, string token, string phoneNumber)
{
ThrowIfDisposed();
- var securityToken = await CreateSecurityTokenAsync(user, cancellationToken);
+ var securityToken = await CreateSecurityTokenAsync(user);
int code;
if (securityToken != null && Int32.TryParse(token, out code))
{
@@ -1604,10 +1509,8 @@ namespace Microsoft.AspNet.Identity
///
///
///
- ///
///
- public virtual async Task VerifyUserTokenAsync(TUser user, string tokenProvider, string purpose, string token,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task VerifyUserTokenAsync(TUser user, string tokenProvider, string purpose, string token)
{
ThrowIfDisposed();
if (user == null)
@@ -1623,7 +1526,7 @@ namespace Microsoft.AspNet.Identity
throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, Resources.NoTokenProvider, tokenProvider));
}
// Make sure the token is valid
- var result = await _tokenProviders[tokenProvider].ValidateAsync(purpose, token, this, user, cancellationToken);
+ var result = await _tokenProviders[tokenProvider].ValidateAsync(purpose, token, this, user);
if (result)
{
@@ -1642,10 +1545,8 @@ namespace Microsoft.AspNet.Identity
///
///
///
- ///
///
- public virtual async Task GenerateUserTokenAsync(TUser user, string tokenProvider, string purpose,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task GenerateUserTokenAsync(TUser user, string tokenProvider, string purpose)
{
ThrowIfDisposed();
if (user == null)
@@ -1661,9 +1562,8 @@ namespace Microsoft.AspNet.Identity
throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, Resources.NoTokenProvider, tokenProvider));
}
- var token = await _tokenProviders[tokenProvider].GenerateAsync(purpose, this, user, cancellationToken);
+ var token = await _tokenProviders[tokenProvider].GenerateAsync(purpose, this, user);
await LogResultAsync(IdentityResult.Success, user);
-
return token;
}
@@ -1699,10 +1599,8 @@ namespace Microsoft.AspNet.Identity
/// Returns a list of valid two factor providers for a user
///
///
- ///
///
- public virtual async Task> GetValidTwoFactorProvidersAsync(TUser user,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task> GetValidTwoFactorProvidersAsync(TUser user)
{
ThrowIfDisposed();
if (user == null)
@@ -1712,7 +1610,7 @@ namespace Microsoft.AspNet.Identity
var results = new List();
foreach (var f in _tokenProviders)
{
- if (await f.Value.CanGenerateTwoFactorTokenAsync(this, user, cancellationToken))
+ if (await f.Value.CanGenerateTwoFactorTokenAsync(this, user))
{
results.Add(f.Key);
}
@@ -1726,10 +1624,8 @@ namespace Microsoft.AspNet.Identity
///
///
///
- ///
///
- public virtual async Task VerifyTwoFactorTokenAsync(TUser user, string tokenProvider, string token,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task VerifyTwoFactorTokenAsync(TUser user, string tokenProvider, string token)
{
ThrowIfDisposed();
if (user == null)
@@ -1742,8 +1638,7 @@ namespace Microsoft.AspNet.Identity
Resources.NoTokenProvider, tokenProvider));
}
// Make sure the token is valid
- var result = await _tokenProviders[tokenProvider].ValidateAsync("TwoFactor", token, this, user, cancellationToken);
-
+ var result = await _tokenProviders[tokenProvider].ValidateAsync("TwoFactor", token, this, user);
if (result)
{
await LogResultAsync(IdentityResult.Success, user);
@@ -1752,7 +1647,6 @@ namespace Microsoft.AspNet.Identity
{
await LogResultAsync(IdentityResult.Failed(ErrorDescriber.InvalidToken()), user);
}
-
return result;
}
@@ -1761,10 +1655,8 @@ namespace Microsoft.AspNet.Identity
///
///
///
- ///
///
- public virtual async Task GenerateTwoFactorTokenAsync(TUser user, string tokenProvider,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task GenerateTwoFactorTokenAsync(TUser user, string tokenProvider)
{
ThrowIfDisposed();
if (user == null)
@@ -1776,9 +1668,8 @@ namespace Microsoft.AspNet.Identity
throw new NotSupportedException(String.Format(CultureInfo.CurrentCulture,
Resources.NoTokenProvider, tokenProvider));
}
- var token = await _tokenProviders[tokenProvider].GenerateAsync("TwoFactor", this, user, cancellationToken);
+ var token = await _tokenProviders[tokenProvider].GenerateAsync("TwoFactor", this, user);
await LogResultAsync(IdentityResult.Success, user);
-
return token;
}
@@ -1788,10 +1679,8 @@ namespace Microsoft.AspNet.Identity
///
///
///
- ///
///
- public virtual async Task NotifyTwoFactorTokenAsync(TUser user, string tokenProvider,
- string token, CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task NotifyTwoFactorTokenAsync(TUser user, string tokenProvider, string token)
{
ThrowIfDisposed();
if (user == null)
@@ -1807,7 +1696,7 @@ namespace Microsoft.AspNet.Identity
throw new NotSupportedException(String.Format(CultureInfo.CurrentCulture,
Resources.NoTokenProvider, tokenProvider));
}
- await _tokenProviders[tokenProvider].NotifyAsync(token, this, user, cancellationToken);
+ await _tokenProviders[tokenProvider].NotifyAsync(token, this, user);
return await LogResultAsync(IdentityResult.Success, user);
}
@@ -1826,10 +1715,8 @@ namespace Microsoft.AspNet.Identity
/// Get a user's two factor provider
///
///
- ///
///
- public virtual async Task GetTwoFactorEnabledAsync(TUser user,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task GetTwoFactorEnabledAsync(TUser user)
{
ThrowIfDisposed();
var store = GetUserTwoFactorStore();
@@ -1837,7 +1724,7 @@ namespace Microsoft.AspNet.Identity
{
throw new ArgumentNullException("user");
}
- return await store.GetTwoFactorEnabledAsync(user, cancellationToken);
+ return await store.GetTwoFactorEnabledAsync(user, CancellationToken);
}
///
@@ -1845,10 +1732,8 @@ namespace Microsoft.AspNet.Identity
///
///
///
- ///
///
- public virtual async Task SetTwoFactorEnabledAsync(TUser user, bool enabled,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task SetTwoFactorEnabledAsync(TUser user, bool enabled)
{
ThrowIfDisposed();
var store = GetUserTwoFactorStore();
@@ -1856,9 +1741,9 @@ namespace Microsoft.AspNet.Identity
{
throw new ArgumentNullException("user");
}
- await store.SetTwoFactorEnabledAsync(user, enabled, cancellationToken);
- await UpdateSecurityStampInternal(user, cancellationToken);
- return await LogResultAsync(await UpdateUserAsync(user, cancellationToken), user);
+ await store.SetTwoFactorEnabledAsync(user, enabled, CancellationToken);
+ await UpdateSecurityStampInternal(user);
+ return await LogResultAsync(await UpdateUserAsync(user), user);
}
// Messaging methods
@@ -1868,10 +1753,8 @@ namespace Microsoft.AspNet.Identity
///
///
///
- ///
///
- public virtual async Task SendMessageAsync(string messageProvider, IdentityMessage message,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task SendMessageAsync(string messageProvider, IdentityMessage message)
{
ThrowIfDisposed();
if (message == null)
@@ -1883,7 +1766,7 @@ namespace Microsoft.AspNet.Identity
throw new NotSupportedException(String.Format(CultureInfo.CurrentCulture,
Resources.NoMessageProvider, messageProvider));
}
- await _msgProviders[messageProvider].SendAsync(message, cancellationToken);
+ await _msgProviders[messageProvider].SendAsync(message, CancellationToken);
return IdentityResult.Success;
}
@@ -1902,10 +1785,8 @@ namespace Microsoft.AspNet.Identity
/// Returns true if the user is locked out
///
///
- ///
///
- public virtual async Task IsLockedOutAsync(TUser user,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task IsLockedOutAsync(TUser user)
{
ThrowIfDisposed();
var store = GetUserLockoutStore();
@@ -1913,11 +1794,11 @@ namespace Microsoft.AspNet.Identity
{
throw new ArgumentNullException("user");
}
- if (!await store.GetLockoutEnabledAsync(user, cancellationToken))
+ if (!await store.GetLockoutEnabledAsync(user, CancellationToken))
{
return false;
}
- var lockoutTime = await store.GetLockoutEndDateAsync(user, cancellationToken).ConfigureAwait((false));
+ var lockoutTime = await store.GetLockoutEndDateAsync(user, CancellationToken);
return lockoutTime >= DateTimeOffset.UtcNow;
}
@@ -1926,10 +1807,8 @@ namespace Microsoft.AspNet.Identity
///
///
///
- ///
///
- public virtual async Task SetLockoutEnabledAsync(TUser user, bool enabled,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task SetLockoutEnabledAsync(TUser user, bool enabled)
{
ThrowIfDisposed();
var store = GetUserLockoutStore();
@@ -1937,18 +1816,16 @@ namespace Microsoft.AspNet.Identity
{
throw new ArgumentNullException("user");
}
- await store.SetLockoutEnabledAsync(user, enabled, cancellationToken);
- return await LogResultAsync(await UpdateUserAsync(user, cancellationToken), user);
+ await store.SetLockoutEnabledAsync(user, enabled, CancellationToken);
+ return await LogResultAsync(await UpdateUserAsync(user), user);
}
///
/// Returns whether the user allows lockout
///
///
- ///
///
- public virtual async Task GetLockoutEnabledAsync(TUser user,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task GetLockoutEnabledAsync(TUser user)
{
ThrowIfDisposed();
var store = GetUserLockoutStore();
@@ -1956,17 +1833,15 @@ namespace Microsoft.AspNet.Identity
{
throw new ArgumentNullException("user");
}
- return await store.GetLockoutEnabledAsync(user, cancellationToken);
+ return await store.GetLockoutEnabledAsync(user, CancellationToken);
}
///
/// Returns the user lockout end date
///
///
- ///
///
- public virtual async Task GetLockoutEndDateAsync(TUser user,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task GetLockoutEndDateAsync(TUser user)
{
ThrowIfDisposed();
var store = GetUserLockoutStore();
@@ -1974,7 +1849,7 @@ namespace Microsoft.AspNet.Identity
{
throw new ArgumentNullException("user");
}
- return await store.GetLockoutEndDateAsync(user, cancellationToken);
+ return await store.GetLockoutEndDateAsync(user, CancellationToken);
}
///
@@ -1982,10 +1857,8 @@ namespace Microsoft.AspNet.Identity
///
///
///
- ///
///
- public virtual async Task SetLockoutEndDateAsync(TUser user, DateTimeOffset? lockoutEnd,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task SetLockoutEndDateAsync(TUser user, DateTimeOffset? lockoutEnd)
{
ThrowIfDisposed();
var store = GetUserLockoutStore();
@@ -1993,12 +1866,12 @@ namespace Microsoft.AspNet.Identity
{
throw new ArgumentNullException("user");
}
- if (!await store.GetLockoutEnabledAsync(user, cancellationToken).ConfigureAwait((false)))
+ if (!await store.GetLockoutEnabledAsync(user, CancellationToken))
{
return await LogResultAsync(IdentityResult.Failed(ErrorDescriber.UserLockoutNotEnabled()), user);
}
- await store.SetLockoutEndDateAsync(user, lockoutEnd, cancellationToken);
- return await LogResultAsync(await UpdateUserAsync(user, cancellationToken), user);
+ await store.SetLockoutEndDateAsync(user, lockoutEnd, CancellationToken);
+ return await LogResultAsync(await UpdateUserAsync(user), user);
}
///
@@ -2007,10 +1880,8 @@ namespace Microsoft.AspNet.Identity
/// DefaultAccountLockoutTimeSpan and the AccessFailedCount will be reset to 0.
///
///
- ///
///
- public virtual async Task AccessFailedAsync(TUser user,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task AccessFailedAsync(TUser user)
{
ThrowIfDisposed();
var store = GetUserLockoutStore();
@@ -2019,25 +1890,23 @@ namespace Microsoft.AspNet.Identity
throw new ArgumentNullException("user");
}
// If this puts the user over the threshold for lockout, lock them out and reset the access failed count
- var count = await store.IncrementAccessFailedCountAsync(user, cancellationToken);
+ var count = await store.IncrementAccessFailedCountAsync(user, CancellationToken);
if (count < Options.Lockout.MaxFailedAccessAttempts)
{
- return await LogResultAsync(await UpdateUserAsync(user, cancellationToken), user);
+ return await LogResultAsync(await UpdateUserAsync(user), user);
}
await store.SetLockoutEndDateAsync(user, DateTimeOffset.UtcNow.Add(Options.Lockout.DefaultLockoutTimeSpan),
- cancellationToken);
- await store.ResetAccessFailedCountAsync(user, cancellationToken);
- return await LogResultAsync(await UpdateUserAsync(user, cancellationToken), user);
+ CancellationToken);
+ await store.ResetAccessFailedCountAsync(user, CancellationToken);
+ return await LogResultAsync(await UpdateUserAsync(user), user);
}
///
/// Resets the access failed count for the user to 0
///
///
- ///
///
- public virtual async Task ResetAccessFailedCountAsync(TUser user,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task ResetAccessFailedCountAsync(TUser user)
{
ThrowIfDisposed();
var store = GetUserLockoutStore();
@@ -2045,18 +1914,16 @@ namespace Microsoft.AspNet.Identity
{
throw new ArgumentNullException("user");
}
- await store.ResetAccessFailedCountAsync(user, cancellationToken);
- return await LogResultAsync(await UpdateUserAsync(user, cancellationToken), user);
+ await store.ResetAccessFailedCountAsync(user, CancellationToken);
+ return await LogResultAsync(await UpdateUserAsync(user), user);
}
///
/// Returns the number of failed access attempts for the user
///
///
- ///
///
- public virtual async Task GetAccessFailedCountAsync(TUser user,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task GetAccessFailedCountAsync(TUser user)
{
ThrowIfDisposed();
var store = GetUserLockoutStore();
@@ -2064,11 +1931,10 @@ namespace Microsoft.AspNet.Identity
{
throw new ArgumentNullException("user");
}
- return await store.GetAccessFailedCountAsync(user, cancellationToken);
+ return await store.GetAccessFailedCountAsync(user, CancellationToken);
}
- public virtual Task> GetUsersForClaimAsync(Claim claim,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual Task> GetUsersForClaimAsync(Claim claim)
{
ThrowIfDisposed();
var store = GetClaimStore();
@@ -2076,17 +1942,15 @@ namespace Microsoft.AspNet.Identity
{
throw new ArgumentNullException("claim");
}
- return store.GetUsersForClaimAsync(claim, cancellationToken);
+ return store.GetUsersForClaimAsync(claim, CancellationToken);
}
///
/// Get all the users in a role
///
///
- ///
///
- public virtual Task> GetUsersInRoleAsync(string roleName,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual Task> GetUsersInRoleAsync(string roleName)
{
ThrowIfDisposed();
var store = GetUserRoleStore();
@@ -2095,7 +1959,7 @@ namespace Microsoft.AspNet.Identity
throw new ArgumentNullException("role");
}
- return store.GetUsersInRoleAsync(roleName, cancellationToken);
+ return store.GetUsersInRoleAsync(roleName, CancellationToken);
}
///
@@ -2109,7 +1973,6 @@ namespace Microsoft.AspNet.Identity
TUser user, [System.Runtime.CompilerServices.CallerMemberName] string methodName = "")
{
result.Log(Logger, Resources.FormatLoggingResultMessage(methodName, await GetUserIdAsync(user)));
-
return result;
}
diff --git a/src/Microsoft.AspNet.Identity/UserValidator.cs b/src/Microsoft.AspNet.Identity/UserValidator.cs
index 06ab306683..b19aaf2cb7 100644
--- a/src/Microsoft.AspNet.Identity/UserValidator.cs
+++ b/src/Microsoft.AspNet.Identity/UserValidator.cs
@@ -32,8 +32,7 @@ namespace Microsoft.AspNet.Identity
///
///
///
- public virtual async Task ValidateAsync(UserManager manager, TUser user,
- CancellationToken cancellationToken = default(CancellationToken))
+ public virtual async Task ValidateAsync(UserManager manager, TUser user)
{
if (manager == null)
{
diff --git a/test/Microsoft.AspNet.Identity.Test/ClaimsIdentityFactoryTest.cs b/test/Microsoft.AspNet.Identity.Test/ClaimsIdentityFactoryTest.cs
index 0693844723..68aa9939d6 100644
--- a/test/Microsoft.AspNet.Identity.Test/ClaimsIdentityFactoryTest.cs
+++ b/test/Microsoft.AspNet.Identity.Test/ClaimsIdentityFactoryTest.cs
@@ -44,18 +44,18 @@ namespace Microsoft.AspNet.Identity.Test
var user = new TestUser { UserName = "Foo" };
userManager.Setup(m => m.SupportsUserClaim).Returns(supportClaims);
userManager.Setup(m => m.SupportsUserRole).Returns(supportRoles);
- userManager.Setup(m => m.GetUserIdAsync(user, CancellationToken.None)).ReturnsAsync(user.Id);
- userManager.Setup(m => m.GetUserNameAsync(user, CancellationToken.None)).ReturnsAsync(user.UserName);
+ userManager.Setup(m => m.GetUserIdAsync(user)).ReturnsAsync(user.Id);
+ userManager.Setup(m => m.GetUserNameAsync(user)).ReturnsAsync(user.UserName);
var roleClaims = new[] { "Admin", "Local" };
if (supportRoles)
{
- userManager.Setup(m => m.GetRolesAsync(user, CancellationToken.None)).ReturnsAsync(roleClaims);
+ userManager.Setup(m => m.GetRolesAsync(user)).ReturnsAsync(roleClaims);
roleManager.Setup(m => m.SupportsRoleClaims).Returns(supportRoleClaims);
}
var userClaims = new[] { new Claim("Whatever", "Value"), new Claim("Whatever2", "Value2") };
if (supportClaims)
{
- userManager.Setup(m => m.GetClaimsAsync(user, CancellationToken.None)).ReturnsAsync(userClaims);
+ userManager.Setup(m => m.GetClaimsAsync(user)).ReturnsAsync(userClaims);
}
userManager.Object.Options = new IdentityOptions();
@@ -65,10 +65,10 @@ namespace Microsoft.AspNet.Identity.Test
var localClaims = new[] { new Claim("LocalClaim1", "Value1"), new Claim("LocalClaim2", "Value2") };
if (supportRoleClaims)
{
- roleManager.Setup(m => m.FindByNameAsync("Admin", CancellationToken.None)).ReturnsAsync(admin);
- roleManager.Setup(m => m.FindByNameAsync("Local", CancellationToken.None)).ReturnsAsync(local);
- roleManager.Setup(m => m.GetClaimsAsync(admin, CancellationToken.None)).ReturnsAsync(adminClaims);
- roleManager.Setup(m => m.GetClaimsAsync(local, CancellationToken.None)).ReturnsAsync(localClaims);
+ roleManager.Setup(m => m.FindByNameAsync("Admin")).ReturnsAsync(admin);
+ roleManager.Setup(m => m.FindByNameAsync("Local")).ReturnsAsync(local);
+ roleManager.Setup(m => m.GetClaimsAsync(admin)).ReturnsAsync(adminClaims);
+ roleManager.Setup(m => m.GetClaimsAsync(local)).ReturnsAsync(localClaims);
}
var options = new Mock>();
diff --git a/test/Microsoft.AspNet.Identity.Test/IdentityBuilderTest.cs b/test/Microsoft.AspNet.Identity.Test/IdentityBuilderTest.cs
index ee4b210d7b..d19a6442a6 100644
--- a/test/Microsoft.AspNet.Identity.Test/IdentityBuilderTest.cs
+++ b/test/Microsoft.AspNet.Identity.Test/IdentityBuilderTest.cs
@@ -209,17 +209,17 @@ namespace Microsoft.AspNet.Identity.Test
throw new NotImplementedException();
}
- public Task ValidateAsync(RoleManager manager, IdentityRole role, CancellationToken cancellationToken = default(CancellationToken))
+ public Task ValidateAsync(RoleManager manager, IdentityRole role)
{
throw new NotImplementedException();
}
- public Task ValidateAsync(UserManager manager, IdentityUser user, CancellationToken cancellationToken = default(CancellationToken))
+ public Task ValidateAsync(UserManager manager, IdentityUser user)
{
throw new NotImplementedException();
}
- public Task ValidateAsync(UserManager manager, IdentityUser user, string password, CancellationToken cancellationToken = default(CancellationToken))
+ public Task ValidateAsync(UserManager manager, IdentityUser user, string password)
{
throw new NotImplementedException();
}
diff --git a/test/Microsoft.AspNet.Identity.Test/SecurityStampValidatorTest.cs b/test/Microsoft.AspNet.Identity.Test/SecurityStampValidatorTest.cs
index 4bad958493..e0dd40bc5a 100644
--- a/test/Microsoft.AspNet.Identity.Test/SecurityStampValidatorTest.cs
+++ b/test/Microsoft.AspNet.Identity.Test/SecurityStampValidatorTest.cs
@@ -48,8 +48,8 @@ namespace Microsoft.AspNet.Identity.Test
contextAccessor.Setup(a => a.Value).Returns(httpContext.Object);
var signInManager = new Mock>(userManager.Object,
contextAccessor.Object, claimsManager.Object, options.Object, null);
- signInManager.Setup(s => s.ValidateSecurityStampAsync(It.IsAny(), user.Id, CancellationToken.None)).ReturnsAsync(user).Verifiable();
- signInManager.Setup(s => s.SignInAsync(user, isPersistent, null, CancellationToken.None)).Returns(Task.FromResult(0)).Verifiable();
+ signInManager.Setup(s => s.ValidateSecurityStampAsync(It.IsAny(), user.Id)).ReturnsAsync(user).Verifiable();
+ signInManager.Setup(s => s.SignInAsync(user, isPersistent, null)).Returns(Task.FromResult(0)).Verifiable();
var services = new ServiceCollection();
services.AddInstance(options.Object);
services.AddInstance(signInManager.Object);
@@ -83,7 +83,7 @@ namespace Microsoft.AspNet.Identity.Test
contextAccessor.Setup(a => a.Value).Returns(httpContext.Object);
var signInManager = new Mock>(userManager.Object,
contextAccessor.Object, claimsManager.Object, options.Object, null);
- signInManager.Setup(s => s.ValidateSecurityStampAsync(It.IsAny(), user.Id, CancellationToken.None)).ReturnsAsync(null).Verifiable();
+ signInManager.Setup(s => s.ValidateSecurityStampAsync(It.IsAny(), user.Id)).ReturnsAsync(null).Verifiable();
var services = new ServiceCollection();
services.AddInstance(options.Object);
services.AddInstance(signInManager.Object);
@@ -117,7 +117,7 @@ namespace Microsoft.AspNet.Identity.Test
contextAccessor.Setup(a => a.Value).Returns(httpContext.Object);
var signInManager = new Mock>(userManager.Object,
contextAccessor.Object, claimsManager.Object, options.Object, null);
- signInManager.Setup(s => s.ValidateSecurityStampAsync(It.IsAny(), user.Id, CancellationToken.None)).ReturnsAsync(null).Verifiable();
+ signInManager.Setup(s => s.ValidateSecurityStampAsync(It.IsAny(), user.Id)).ReturnsAsync(null).Verifiable();
var services = new ServiceCollection();
services.AddInstance(options.Object);
services.AddInstance(signInManager.Object);
@@ -151,8 +151,8 @@ namespace Microsoft.AspNet.Identity.Test
contextAccessor.Setup(a => a.Value).Returns(httpContext.Object);
var signInManager = new Mock>(userManager.Object,
contextAccessor.Object, claimsManager.Object, options.Object, null);
- signInManager.Setup(s => s.ValidateSecurityStampAsync(It.IsAny(), user.Id, CancellationToken.None)).Throws(new Exception("Shouldn't be called"));
- signInManager.Setup(s => s.SignInAsync(user, false, null, CancellationToken.None)).Throws(new Exception("Shouldn't be called"));
+ signInManager.Setup(s => s.ValidateSecurityStampAsync(It.IsAny(), user.Id)).Throws(new Exception("Shouldn't be called"));
+ signInManager.Setup(s => s.SignInAsync(user, false, null)).Throws(new Exception("Shouldn't be called"));
var services = new ServiceCollection();
services.AddInstance(options.Object);
services.AddInstance(signInManager.Object);
diff --git a/test/Microsoft.AspNet.Identity.Test/SignInManagerTest.cs b/test/Microsoft.AspNet.Identity.Test/SignInManagerTest.cs
index be4641923b..c53cf80b8d 100644
--- a/test/Microsoft.AspNet.Identity.Test/SignInManagerTest.cs
+++ b/test/Microsoft.AspNet.Identity.Test/SignInManagerTest.cs
@@ -89,7 +89,7 @@ namespace Microsoft.AspNet.Identity.Test
// var identityFactory = new Mock>();
// const string authType = "Test";
// var testIdentity = new ClaimsIdentity(authType);
- // identityFactory.Setup(s => s.CreateAsync(userManager, user, authType, CancellationToken.None)).ReturnsAsync(testIdentity).Verifiable();
+ // identityFactory.Setup(s => s.CreateAsync(userManager, user, authType)).ReturnsAsync(testIdentity).Verifiable();
// userManager.ClaimsIdentityFactory = identityFactory.Object;
// var context = new Mock();
// var response = new Mock();
@@ -116,9 +116,9 @@ namespace Microsoft.AspNet.Identity.Test
var user = new TestUser { UserName = "Foo" };
var manager = MockHelpers.MockUserManager();
manager.Setup(m => m.SupportsUserLockout).Returns(true).Verifiable();
- manager.Setup(m => m.IsLockedOutAsync(user, CancellationToken.None)).ReturnsAsync(true).Verifiable();
- manager.Setup(m => m.FindByNameAsync(user.UserName, CancellationToken.None)).ReturnsAsync(user).Verifiable();
- manager.Setup(m => m.GetUserIdAsync(user, CancellationToken.None)).ReturnsAsync(user.Id.ToString()).Verifiable();
+ manager.Setup(m => m.IsLockedOutAsync(user)).ReturnsAsync(true).Verifiable();
+ manager.Setup(m => m.FindByNameAsync(user.UserName)).ReturnsAsync(user).Verifiable();
+ manager.Setup(m => m.GetUserIdAsync(user)).ReturnsAsync(user.Id.ToString()).Verifiable();
var context = new Mock();
var contextAccessor = new Mock();
@@ -152,11 +152,11 @@ namespace Microsoft.AspNet.Identity.Test
var user = new TestUser { UserName = "Foo" };
var manager = MockHelpers.MockUserManager();
manager.Setup(m => m.SupportsUserLockout).Returns(true).Verifiable();
- manager.Setup(m => m.IsLockedOutAsync(user, CancellationToken.None)).ReturnsAsync(false).Verifiable();
- manager.Setup(m => m.FindByNameAsync(user.UserName, CancellationToken.None)).ReturnsAsync(user).Verifiable();
- manager.Setup(m => m.CheckPasswordAsync(user, "password", CancellationToken.None)).ReturnsAsync(true).Verifiable();
- manager.Setup(m => m.ResetAccessFailedCountAsync(user, CancellationToken.None)).ReturnsAsync(IdentityResult.Success).Verifiable();
- manager.Setup(m => m.GetUserIdAsync(user, CancellationToken.None)).ReturnsAsync(user.Id.ToString()).Verifiable();
+ manager.Setup(m => m.IsLockedOutAsync(user)).ReturnsAsync(false).Verifiable();
+ manager.Setup(m => m.FindByNameAsync(user.UserName)).ReturnsAsync(user).Verifiable();
+ manager.Setup(m => m.CheckPasswordAsync(user, "password")).ReturnsAsync(true).Verifiable();
+ manager.Setup(m => m.ResetAccessFailedCountAsync(user)).ReturnsAsync(IdentityResult.Success).Verifiable();
+ manager.Setup(m => m.GetUserIdAsync(user)).ReturnsAsync(user.Id.ToString()).Verifiable();
var context = new Mock();
var response = new Mock();
@@ -169,7 +169,7 @@ namespace Microsoft.AspNet.Identity.Test
var options = new Mock>();
options.Setup(a => a.Options).Returns(identityOptions);
var claimsFactory = new Mock>(manager.Object, roleManager.Object, options.Object);
- claimsFactory.Setup(m => m.CreateAsync(user, CancellationToken.None)).ReturnsAsync(new ClaimsIdentity("Microsoft.AspNet.Identity")).Verifiable();
+ claimsFactory.Setup(m => m.CreateAsync(user)).ReturnsAsync(new ClaimsIdentity("Microsoft.AspNet.Identity")).Verifiable();
var logStore = new StringBuilder();
var logger = MockHelpers.MockILogger>(logStore);
var helper = new SignInManager(manager.Object, contextAccessor.Object, claimsFactory.Object, options.Object, logger.Object);
@@ -195,11 +195,11 @@ namespace Microsoft.AspNet.Identity.Test
var user = new TestUser { UserName = "Foo" };
var manager = MockHelpers.MockUserManager();
manager.Setup(m => m.SupportsUserLockout).Returns(true).Verifiable();
- manager.Setup(m => m.IsLockedOutAsync(user, CancellationToken.None)).ReturnsAsync(false).Verifiable();
- manager.Setup(m => m.FindByNameAsync(user.UserName, CancellationToken.None)).ReturnsAsync(user).Verifiable();
- manager.Setup(m => m.CheckPasswordAsync(user, "password", CancellationToken.None)).ReturnsAsync(true).Verifiable();
- manager.Setup(m => m.ResetAccessFailedCountAsync(user, CancellationToken.None)).ReturnsAsync(IdentityResult.Success).Verifiable();
- manager.Setup(m => m.GetUserIdAsync(user, CancellationToken.None)).ReturnsAsync(user.Id.ToString()).Verifiable();
+ manager.Setup(m => m.IsLockedOutAsync(user)).ReturnsAsync(false).Verifiable();
+ manager.Setup(m => m.FindByNameAsync(user.UserName)).ReturnsAsync(user).Verifiable();
+ manager.Setup(m => m.CheckPasswordAsync(user, "password")).ReturnsAsync(true).Verifiable();
+ manager.Setup(m => m.ResetAccessFailedCountAsync(user)).ReturnsAsync(IdentityResult.Success).Verifiable();
+ manager.Setup(m => m.GetUserIdAsync(user)).ReturnsAsync(user.Id.ToString()).Verifiable();
var context = new Mock();
var response = new Mock();
@@ -236,19 +236,19 @@ namespace Microsoft.AspNet.Identity.Test
manager.Setup(m => m.SupportsUserLockout).Returns(supportsLockout).Verifiable();
if (supportsLockout)
{
- manager.Setup(m => m.IsLockedOutAsync(user, CancellationToken.None)).ReturnsAsync(false).Verifiable();
+ manager.Setup(m => m.IsLockedOutAsync(user)).ReturnsAsync(false).Verifiable();
}
IList providers = new List();
providers.Add("PhoneNumber");
- manager.Setup(m => m.GetValidTwoFactorProvidersAsync(user, CancellationToken.None)).Returns(Task.FromResult(providers)).Verifiable();
+ manager.Setup(m => m.GetValidTwoFactorProvidersAsync(user)).Returns(Task.FromResult(providers)).Verifiable();
manager.Setup(m => m.SupportsUserTwoFactor).Returns(true).Verifiable();
- manager.Setup(m => m.GetTwoFactorEnabledAsync(user, CancellationToken.None)).ReturnsAsync(true).Verifiable();
- manager.Setup(m => m.FindByNameAsync(user.UserName, CancellationToken.None)).ReturnsAsync(user).Verifiable();
- manager.Setup(m => m.GetUserIdAsync(user, CancellationToken.None)).ReturnsAsync(user.Id).Verifiable();
- manager.Setup(m => m.CheckPasswordAsync(user, "password", CancellationToken.None)).ReturnsAsync(true).Verifiable();
+ manager.Setup(m => m.GetTwoFactorEnabledAsync(user)).ReturnsAsync(true).Verifiable();
+ manager.Setup(m => m.FindByNameAsync(user.UserName)).ReturnsAsync(user).Verifiable();
+ manager.Setup(m => m.GetUserIdAsync(user)).ReturnsAsync(user.Id).Verifiable();
+ manager.Setup(m => m.CheckPasswordAsync(user, "password")).ReturnsAsync(true).Verifiable();
if (supportsLockout)
{
- manager.Setup(m => m.ResetAccessFailedCountAsync(user, CancellationToken.None)).ReturnsAsync(IdentityResult.Success).Verifiable();
+ manager.Setup(m => m.ResetAccessFailedCountAsync(user)).ReturnsAsync(IdentityResult.Success).Verifiable();
}
var context = new Mock();
var response = new Mock();
@@ -293,10 +293,10 @@ namespace Microsoft.AspNet.Identity.Test
manager.Setup(m => m.SupportsUserLockout).Returns(supportsLockout).Verifiable();
if (supportsLockout)
{
- manager.Setup(m => m.IsLockedOutAsync(user, CancellationToken.None)).ReturnsAsync(false).Verifiable();
+ manager.Setup(m => m.IsLockedOutAsync(user)).ReturnsAsync(false).Verifiable();
}
- manager.Setup(m => m.FindByLoginAsync(loginProvider, providerKey, CancellationToken.None)).ReturnsAsync(user).Verifiable();
- manager.Setup(m => m.GetUserIdAsync(user, CancellationToken.None)).ReturnsAsync(user.Id.ToString()).Verifiable();
+ manager.Setup(m => m.FindByLoginAsync(loginProvider, providerKey)).ReturnsAsync(user).Verifiable();
+ manager.Setup(m => m.GetUserIdAsync(user)).ReturnsAsync(user.Id.ToString()).Verifiable();
var context = new Mock();
var response = new Mock();
@@ -312,7 +312,7 @@ namespace Microsoft.AspNet.Identity.Test
var options = new Mock>();
options.Setup(a => a.Options).Returns(identityOptions);
var claimsFactory = new Mock>(manager.Object, roleManager.Object, options.Object);
- claimsFactory.Setup(m => m.CreateAsync(user, CancellationToken.None)).ReturnsAsync(new ClaimsIdentity("Microsoft.AspNet.Identity")).Verifiable();
+ claimsFactory.Setup(m => m.CreateAsync(user)).ReturnsAsync(new ClaimsIdentity("Microsoft.AspNet.Identity")).Verifiable();
var logStore = new StringBuilder();
var logger = MockHelpers.MockILogger>(logStore);
var helper = new SignInManager(manager.Object, contextAccessor.Object, claimsFactory.Object, options.Object, logger.Object);
@@ -358,13 +358,13 @@ namespace Microsoft.AspNet.Identity.Test
manager.Setup(m => m.SupportsUserLockout).Returns(supportsLockout).Verifiable();
if (supportsLockout)
{
- manager.Setup(m => m.IsLockedOutAsync(user, CancellationToken.None)).ReturnsAsync(false).Verifiable();
- manager.Setup(m => m.ResetAccessFailedCountAsync(user, CancellationToken.None)).ReturnsAsync(IdentityResult.Success).Verifiable();
+ manager.Setup(m => m.IsLockedOutAsync(user)).ReturnsAsync(false).Verifiable();
+ manager.Setup(m => m.ResetAccessFailedCountAsync(user)).ReturnsAsync(IdentityResult.Success).Verifiable();
}
- manager.Setup(m => m.FindByIdAsync(user.Id, CancellationToken.None)).ReturnsAsync(user).Verifiable();
- manager.Setup(m => m.VerifyTwoFactorTokenAsync(user, provider, code, CancellationToken.None)).ReturnsAsync(true).Verifiable();
- manager.Setup(m => m.GetUserIdAsync(user, CancellationToken.None)).ReturnsAsync(user.Id).Verifiable();
- manager.Setup(m => m.GetUserNameAsync(user, CancellationToken.None)).ReturnsAsync(user.UserName).Verifiable();
+ manager.Setup(m => m.FindByIdAsync(user.Id)).ReturnsAsync(user).Verifiable();
+ manager.Setup(m => m.VerifyTwoFactorTokenAsync(user, provider, code)).ReturnsAsync(true).Verifiable();
+ manager.Setup(m => m.GetUserIdAsync(user)).ReturnsAsync(user.Id).Verifiable();
+ manager.Setup(m => m.GetUserNameAsync(user)).ReturnsAsync(user.UserName).Verifiable();
var context = new Mock();
var response = new Mock();
var contextAccessor = new Mock();
@@ -433,7 +433,7 @@ namespace Microsoft.AspNet.Identity.Test
options.Setup(a => a.Options).Returns(identityOptions);
var claimsFactory = new ClaimsIdentityFactory(manager.Object, roleManager.Object, options.Object);
- manager.Setup(m => m.GetUserIdAsync(user, CancellationToken.None)).ReturnsAsync(user.Id).Verifiable();
+ manager.Setup(m => m.GetUserIdAsync(user)).ReturnsAsync(user.Id).Verifiable();
context.Setup(c => c.Response).Returns(response.Object).Verifiable();
response.Setup(r => r.SignIn(
It.Is(v => v.IsPersistent == true),
@@ -463,16 +463,16 @@ namespace Microsoft.AspNet.Identity.Test
// Setup
var user = new TestUser { UserName = "Foo" };
var manager = MockHelpers.MockUserManager();
- manager.Setup(m => m.GetTwoFactorEnabledAsync(user, CancellationToken.None)).ReturnsAsync(true).Verifiable();
+ manager.Setup(m => m.GetTwoFactorEnabledAsync(user)).ReturnsAsync(true).Verifiable();
IList providers = new List();
providers.Add("PhoneNumber");
- manager.Setup(m => m.GetValidTwoFactorProvidersAsync(user, CancellationToken.None)).Returns(Task.FromResult(providers)).Verifiable();
+ manager.Setup(m => m.GetValidTwoFactorProvidersAsync(user)).Returns(Task.FromResult(providers)).Verifiable();
manager.Setup(m => m.SupportsUserLockout).Returns(true).Verifiable();
manager.Setup(m => m.SupportsUserTwoFactor).Returns(true).Verifiable();
- manager.Setup(m => m.IsLockedOutAsync(user, CancellationToken.None)).ReturnsAsync(false).Verifiable();
- manager.Setup(m => m.FindByNameAsync(user.UserName, CancellationToken.None)).ReturnsAsync(user).Verifiable();
- manager.Setup(m => m.GetUserIdAsync(user, CancellationToken.None)).ReturnsAsync(user.Id).Verifiable();
- manager.Setup(m => m.CheckPasswordAsync(user, "password", CancellationToken.None)).ReturnsAsync(true).Verifiable();
+ manager.Setup(m => m.IsLockedOutAsync(user)).ReturnsAsync(false).Verifiable();
+ manager.Setup(m => m.FindByNameAsync(user.UserName)).ReturnsAsync(user).Verifiable();
+ manager.Setup(m => m.GetUserIdAsync(user)).ReturnsAsync(user.Id).Verifiable();
+ manager.Setup(m => m.CheckPasswordAsync(user, "password")).ReturnsAsync(true).Verifiable();
var context = new Mock();
var response = new Mock();
context.Setup(c => c.Response).Returns(response.Object).Verifiable();
@@ -488,7 +488,7 @@ namespace Microsoft.AspNet.Identity.Test
var options = new Mock>();
options.Setup(a => a.Options).Returns(identityOptions);
var claimsFactory = new Mock>(manager.Object, roleManager.Object, options.Object);
- claimsFactory.Setup(m => m.CreateAsync(user, CancellationToken.None)).ReturnsAsync(new ClaimsIdentity(IdentityOptions.ApplicationCookieAuthenticationType)).Verifiable();
+ claimsFactory.Setup(m => m.CreateAsync(user)).ReturnsAsync(new ClaimsIdentity(IdentityOptions.ApplicationCookieAuthenticationType)).Verifiable();
var helper = new SignInManager(manager.Object, contextAccessor.Object, claimsFactory.Object, options.Object);
// Act
@@ -545,10 +545,10 @@ namespace Microsoft.AspNet.Identity.Test
var user = new TestUser { UserName = "Foo" };
var manager = MockHelpers.MockUserManager();
manager.Setup(m => m.SupportsUserLockout).Returns(true).Verifiable();
- manager.Setup(m => m.IsLockedOutAsync(user, CancellationToken.None)).ReturnsAsync(false).Verifiable();
- manager.Setup(m => m.FindByNameAsync(user.UserName, CancellationToken.None)).ReturnsAsync(user).Verifiable();
- manager.Setup(m => m.CheckPasswordAsync(user, "bogus", CancellationToken.None)).ReturnsAsync(false).Verifiable();
- manager.Setup(m => m.GetUserIdAsync(user, CancellationToken.None)).ReturnsAsync(user.Id.ToString()).Verifiable();
+ manager.Setup(m => m.IsLockedOutAsync(user)).ReturnsAsync(false).Verifiable();
+ manager.Setup(m => m.FindByNameAsync(user.UserName)).ReturnsAsync(user).Verifiable();
+ manager.Setup(m => m.CheckPasswordAsync(user, "bogus")).ReturnsAsync(false).Verifiable();
+ manager.Setup(m => m.GetUserIdAsync(user)).ReturnsAsync(user.Id.ToString()).Verifiable();
var context = new Mock();
var contextAccessor = new Mock();
contextAccessor.Setup(a => a.Value).Returns(context.Object);
@@ -577,7 +577,7 @@ namespace Microsoft.AspNet.Identity.Test
{
// Setup
var manager = MockHelpers.MockUserManager();
- manager.Setup(m => m.FindByNameAsync("bogus", CancellationToken.None)).ReturnsAsync(null).Verifiable();
+ manager.Setup(m => m.FindByNameAsync("bogus")).ReturnsAsync(null).Verifiable();
var context = new Mock();
var contextAccessor = new Mock();
contextAccessor.Setup(a => a.Value).Returns(context.Object);
@@ -605,15 +605,15 @@ namespace Microsoft.AspNet.Identity.Test
var user = new TestUser { UserName = "Foo" };
var manager = MockHelpers.MockUserManager();
var lockedout = false;
- manager.Setup(m => m.AccessFailedAsync(user, CancellationToken.None)).Returns(() =>
+ manager.Setup(m => m.AccessFailedAsync(user)).Returns(() =>
{
lockedout = true;
return Task.FromResult(IdentityResult.Success);
}).Verifiable();
manager.Setup(m => m.SupportsUserLockout).Returns(true).Verifiable();
- manager.Setup(m => m.IsLockedOutAsync(user, CancellationToken.None)).Returns(() => Task.FromResult(lockedout));
- manager.Setup(m => m.FindByNameAsync(user.UserName, CancellationToken.None)).ReturnsAsync(user).Verifiable();
- manager.Setup(m => m.CheckPasswordAsync(user, "bogus", CancellationToken.None)).ReturnsAsync(false).Verifiable();
+ manager.Setup(m => m.IsLockedOutAsync(user)).Returns(() => Task.FromResult(lockedout));
+ manager.Setup(m => m.FindByNameAsync(user.UserName)).ReturnsAsync(user).Verifiable();
+ manager.Setup(m => m.CheckPasswordAsync(user, "bogus")).ReturnsAsync(false).Verifiable();
var context = new Mock();
var contextAccessor = new Mock();
contextAccessor.Setup(a => a.Value).Returns(context.Object);
@@ -641,17 +641,17 @@ namespace Microsoft.AspNet.Identity.Test
// Setup
var user = new TestUser { UserName = "Foo" };
var manager = MockHelpers.MockUserManager();
- manager.Setup(m => m.IsEmailConfirmedAsync(user, CancellationToken.None)).ReturnsAsync(confirmed).Verifiable();
+ manager.Setup(m => m.IsEmailConfirmedAsync(user)).ReturnsAsync(confirmed).Verifiable();
if (confirmed)
{
- manager.Setup(m => m.CheckPasswordAsync(user, "password", CancellationToken.None)).ReturnsAsync(true).Verifiable();
+ manager.Setup(m => m.CheckPasswordAsync(user, "password")).ReturnsAsync(true).Verifiable();
}
- manager.Setup(m => m.GetUserIdAsync(user, CancellationToken.None)).ReturnsAsync(user.Id.ToString()).Verifiable();
+ manager.Setup(m => m.GetUserIdAsync(user)).ReturnsAsync(user.Id.ToString()).Verifiable();
var context = new Mock();
var response = new Mock();
if (confirmed)
{
- manager.Setup(m => m.CheckPasswordAsync(user, "password", CancellationToken.None)).ReturnsAsync(true).Verifiable();
+ manager.Setup(m => m.CheckPasswordAsync(user, "password")).ReturnsAsync(true).Verifiable();
context.Setup(c => c.Response).Returns(response.Object).Verifiable();
response.Setup(r => r.SignIn(It.Is(v => v.IsPersistent == false), It.IsAny())).Verifiable();
}
@@ -690,13 +690,13 @@ namespace Microsoft.AspNet.Identity.Test
// Setup
var user = new TestUser { UserName = "Foo" };
var manager = MockHelpers.MockUserManager();
- manager.Setup(m => m.IsPhoneNumberConfirmedAsync(user, CancellationToken.None)).ReturnsAsync(confirmed).Verifiable();
- manager.Setup(m => m.GetUserIdAsync(user, CancellationToken.None)).ReturnsAsync(user.Id.ToString()).Verifiable();
+ manager.Setup(m => m.IsPhoneNumberConfirmedAsync(user)).ReturnsAsync(confirmed).Verifiable();
+ manager.Setup(m => m.GetUserIdAsync(user)).ReturnsAsync(user.Id.ToString()).Verifiable();
var context = new Mock();
var response = new Mock();
if (confirmed)
{
- manager.Setup(m => m.CheckPasswordAsync(user, "password", CancellationToken.None)).ReturnsAsync(true).Verifiable();
+ manager.Setup(m => m.CheckPasswordAsync(user, "password")).ReturnsAsync(true).Verifiable();
context.Setup(c => c.Response).Returns(response.Object).Verifiable();
response.Setup(r => r.SignIn(It.Is(v => v.IsPersistent == false), It.IsAny())).Verifiable();
}
diff --git a/test/Microsoft.AspNet.Identity.Test/UserManagerTest.cs b/test/Microsoft.AspNet.Identity.Test/UserManagerTest.cs
index 62f1e77917..099e4faa36 100644
--- a/test/Microsoft.AspNet.Identity.Test/UserManagerTest.cs
+++ b/test/Microsoft.AspNet.Identity.Test/UserManagerTest.cs
@@ -817,7 +817,7 @@ namespace Microsoft.AspNet.Identity.Test
{
public static readonly IdentityError ErrorMessage = new IdentityError { Description = "I'm Bad." };
- public Task ValidateAsync(UserManager manager, TUser user, string password, CancellationToken cancellationToken = default(CancellationToken))
+ public Task ValidateAsync(UserManager manager, TUser user, string password)
{
return Task.FromResult(IdentityResult.Failed(ErrorMessage));
}
@@ -1088,23 +1088,22 @@ namespace Microsoft.AspNet.Identity.Test
{
public string Name { get; } = "Noop";
- public Task GenerateAsync(string purpose, UserManager manager, TestUser user, CancellationToken cancellationToken = default(CancellationToken))
+ public Task GenerateAsync(string purpose, UserManager manager, TestUser user)
{
return Task.FromResult("Test");
}
- public Task ValidateAsync(string purpose, string token, UserManager manager,
- TestUser user, CancellationToken cancellationToken = default(CancellationToken))
+ public Task ValidateAsync(string purpose, string token, UserManager manager, TestUser user)
{
return Task.FromResult(true);
}
- public Task NotifyAsync(string token, UserManager manager, TestUser user, CancellationToken cancellationToken = default(CancellationToken))
+ public Task NotifyAsync(string token, UserManager manager, TestUser user)
{
return Task.FromResult(0);
}
- public Task CanGenerateTwoFactorTokenAsync(UserManager manager, TestUser user, CancellationToken cancellationToken = default(CancellationToken))
+ public Task CanGenerateTwoFactorTokenAsync(UserManager manager, TestUser user)
{
return Task.FromResult(true);
}
diff --git a/test/Shared/ApiConsistencyTestBase.cs b/test/Shared/ApiConsistencyTestBase.cs
index b1acf68be9..6b7c70b88f 100644
--- a/test/Shared/ApiConsistencyTestBase.cs
+++ b/test/Shared/ApiConsistencyTestBase.cs
@@ -71,7 +71,7 @@ namespace Microsoft.AspNet.Identity.Test
//}
[Fact]
- public void Async_methods_should_have_overload_with_cancellation_token_and_end_with_async_suffix()
+ public void Async_methods_should_end_with_async_suffix()
{
var asyncMethods
= (from type in GetAllTypes(TargetAssembly.GetTypes())
@@ -81,30 +81,6 @@ namespace Microsoft.AspNet.Identity.Test
where typeof(Task).IsAssignableFrom(method.ReturnType)
select method).ToList();
- var asyncMethodsWithToken
- = (from method in asyncMethods
- where method.GetParameters().Any(pi => pi.ParameterType == typeof(CancellationToken))
- select method).ToList();
-
- var asyncMethodsWithoutToken
- = (from method in asyncMethods
- where method.GetParameters().All(pi => pi.ParameterType != typeof(CancellationToken))
- select method).ToList();
-
- var missingOverloads
- = (from methodWithoutToken in asyncMethodsWithoutToken
- where !asyncMethodsWithToken
- .Any(methodWithToken => methodWithoutToken.Name == methodWithToken.Name
- && methodWithoutToken.ReflectedType == methodWithToken.ReflectedType)
- // ReSharper disable once PossibleNullReferenceException
- select methodWithoutToken.DeclaringType.Name + "." + methodWithoutToken.Name)
- .Except(GetCancellationTokenExceptions())
- .ToList();
-
- Assert.False(
- missingOverloads.Any(),
- "\r\n-- Missing async overloads --\r\n" + string.Join("\r\n", missingOverloads));
-
var missingSuffixMethods
= asyncMethods
.Where(method => !method.Name.EndsWith("Async"))
diff --git a/test/Shared/MockHelpers.cs b/test/Shared/MockHelpers.cs
index 15b7666458..ea3ebd0a6f 100644
--- a/test/Shared/MockHelpers.cs
+++ b/test/Shared/MockHelpers.cs
@@ -18,7 +18,7 @@ namespace Microsoft.AspNet.Identity.Test
public static Mock> MockUserManager() where TUser : class
{
var store = new Mock>();
- var mgr = new Mock>(store.Object, null, null, null, null, null, null, null, null, null);
+ var mgr = new Mock>(store.Object, null, null, null, null, null, null, null, null, null, null);
mgr.Object.UserValidators.Add(new UserValidator());
mgr.Object.PasswordValidators.Add(new PasswordValidator());
return mgr;
@@ -29,7 +29,7 @@ namespace Microsoft.AspNet.Identity.Test
store = store ?? new Mock>().Object;
var roles = new List>();
roles.Add(new RoleValidator());
- return new Mock>(store, roles, null, null, null);
+ return new Mock>(store, roles, null, null, null, null);
}
public static Mock> MockILogger(StringBuilder logStore = null) where T : class
@@ -53,7 +53,7 @@ namespace Microsoft.AspNet.Identity.Test
var userManager = new UserManager