本文整理汇总了C#中UserStore.ResetAccessFailedCountAsync方法的典型用法代码示例。如果您正苦于以下问题:C# UserStore.ResetAccessFailedCountAsync方法的具体用法?C# UserStore.ResetAccessFailedCountAsync怎么用?C# UserStore.ResetAccessFailedCountAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserStore
的用法示例。
在下文中一共展示了UserStore.ResetAccessFailedCountAsync方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AccessFailedCount
public void AccessFailedCount()
{
using (UserStore<IdentityUser> store = new UserStore<IdentityUser>())
{
using (UserManager<IdentityUser> manager = new UserManager<IdentityUser>(store))
{
manager.MaxFailedAccessAttemptsBeforeLockout = 2;
var user = CreateTestUser();
var taskUser = manager.GetAccessFailedCountAsync(user.Id);
taskUser.Wait();
Assert.AreEqual<int>(user.AccessFailedCount, taskUser.Result, "AccessFailedCount not equal");
var taskAccessFailed = manager.AccessFailedAsync(user.Id);
taskAccessFailed.Wait();
Assert.IsTrue(taskAccessFailed.Result.Succeeded, string.Concat(taskAccessFailed.Result.Errors));
user = manager.FindById(user.Id);
var taskAccessReset = manager.ResetAccessFailedCountAsync(user.Id);
taskAccessReset.Wait();
Assert.IsTrue(taskAccessReset.Result.Succeeded, string.Concat(taskAccessReset.Result.Errors));
try
{
var task = store.GetAccessFailedCountAsync(null);
task.Wait();
}
catch (Exception ex)
{
Assert.IsNotNull(ex, "Argument exception not raised");
}
try
{
var task = store.IncrementAccessFailedCountAsync(null);
task.Wait();
}
catch (Exception ex)
{
Assert.IsNotNull(ex, "Argument exception not raised");
}
try
{
var task = store.ResetAccessFailedCountAsync(null);
task.Wait();
}
catch (Exception ex)
{
Assert.IsNotNull(ex, "Argument exception not raised");
}
}
}
}
示例2: ResetAccessFailedCountAsync_GivenAUser_ResetsFailedCountToZero
public async void ResetAccessFailedCountAsync_GivenAUser_ResetsFailedCountToZero()
{
var applicationDatabaseConfiguration = new ApplicationDatabaseConfiguration();
var userStore = new UserStore<User>(applicationDatabaseConfiguration);
var user = new User
{
Email = "[email protected]",
IsEmailConfirmed = true,
PasswordHash = "PasswordHash",
PhoneNumber = "PhoneNumber",
IsPhoneNumberConfirmed = true,
IsTwoFactorEnabled = false,
LockoutEndDateUtc = null,
IsLockoutEnabled = false,
AccessFailedCount = 0,
UserName = "UserName",
IsAccountActive = true
};
await userStore.CreateAsync(user);
await userStore.IncrementAccessFailedCountAsync(user);
await userStore.ResetAccessFailedCountAsync(user);
var failedCount = await userStore.GetAccessFailedCountAsync(user);
failedCount.Should().Be(0);
}