commit
ee8e882d17
|
|
@ -83,7 +83,7 @@ namespace Microsoft.AspNetCore.Identity.UI.Pages.Account.Internal
|
||||||
{
|
{
|
||||||
// This doesn't count login failures towards account lockout
|
// This doesn't count login failures towards account lockout
|
||||||
// To enable password failures to trigger account lockout, set lockoutOnFailure: true
|
// To enable password failures to trigger account lockout, set lockoutOnFailure: true
|
||||||
var result = await _signInManager.PasswordSignInAsync(Input.Email, Input.Password, Input.RememberMe, lockoutOnFailure: true);
|
var result = await _signInManager.PasswordSignInAsync(Input.Email, Input.Password, Input.RememberMe, lockoutOnFailure: false);
|
||||||
if (result.Succeeded)
|
if (result.Succeeded)
|
||||||
{
|
{
|
||||||
_logger.LogInformation("User logged in.");
|
_logger.LogInformation("User logged in.");
|
||||||
|
|
|
||||||
|
|
@ -362,7 +362,7 @@ namespace Microsoft.AspNetCore.Identity.FunctionalTests
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task UserLockedOut_AfterMaxFailedAccessAttempts_WithGlobalAuthorizeFilter()
|
public async Task UserNotLockedOut_AfterMaxFailedAccessAttempts_WithGlobalAuthorizeFilter()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var emailSender = new ContosoEmailSender();
|
var emailSender = new ContosoEmailSender();
|
||||||
|
|
@ -383,7 +383,7 @@ namespace Microsoft.AspNetCore.Identity.FunctionalTests
|
||||||
await UserStories.ConfirmEmailAsync(registrationEmail, client);
|
await UserStories.ConfirmEmailAsync(registrationEmail, client);
|
||||||
|
|
||||||
// Act & Assert
|
// Act & Assert
|
||||||
await UserStories.LockoutExistingUserAsync(newClient, userName, wrongPassword);
|
await UserStories.LoginFailsWithWrongPasswordAsync(newClient, userName, wrongPassword);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -64,6 +64,15 @@ namespace Microsoft.AspNetCore.Identity.FunctionalTests.Account
|
||||||
Context.WithAuthenticatedUser());
|
Context.WithAuthenticatedUser());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task LoginWrongPasswordAsync(string userName, string password)
|
||||||
|
{
|
||||||
|
var failedLogin = await SendLoginForm(userName, password);
|
||||||
|
|
||||||
|
ResponseAssert.IsOK(failedLogin);
|
||||||
|
var content = await failedLogin.Content.ReadAsStringAsync();
|
||||||
|
Assert.Contains("Invalid login attempt.", content);
|
||||||
|
}
|
||||||
|
|
||||||
public async Task<DefaultUIPage> LockoutUserAsync(string userName, string password)
|
public async Task<DefaultUIPage> LockoutUserAsync(string userName, string password)
|
||||||
{
|
{
|
||||||
var loginAttempt = await SendLoginForm(userName, password);
|
var loginAttempt = await SendLoginForm(userName, password);
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,15 @@ namespace Microsoft.AspNetCore.Identity.FunctionalTests
|
||||||
return await login.LoginValidUserAsync(userName, password);
|
return await login.LoginValidUserAsync(userName, password);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal static async Task LoginFailsWithWrongPasswordAsync(HttpClient client, string userName, string password)
|
||||||
|
{
|
||||||
|
var index = await Index.CreateAsync(client);
|
||||||
|
|
||||||
|
var login = await index.ClickLoginLinkAsync();
|
||||||
|
|
||||||
|
await login.LoginWrongPasswordAsync(userName, password);
|
||||||
|
}
|
||||||
|
|
||||||
internal static async Task<DefaultUIPage> LockoutExistingUserAsync(HttpClient client, string userName, string password)
|
internal static async Task<DefaultUIPage> LockoutExistingUserAsync(HttpClient client, string userName, string password)
|
||||||
{
|
{
|
||||||
var index = await Index.CreateAsync(client);
|
var index = await Index.CreateAsync(client);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue