diff --git a/src/UI/Areas/Identity/Pages/Account/Login.cshtml.cs b/src/UI/Areas/Identity/Pages/Account/Login.cshtml.cs index 733913be01e466523c2701df9616b7f1b47d87a2..6c01edd524b3f8ce31490bf534b4db3789601174 100644 --- a/src/UI/Areas/Identity/Pages/Account/Login.cshtml.cs +++ b/src/UI/Areas/Identity/Pages/Account/Login.cshtml.cs @@ -83,7 +83,7 @@ namespace Microsoft.AspNetCore.Identity.UI.Pages.Account.Internal { // This doesn't count login failures towards account lockout // 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) { _logger.LogInformation("User logged in."); diff --git a/test/Identity.FunctionalTests/LoginTests.cs b/test/Identity.FunctionalTests/LoginTests.cs index 4aa9a6b7a771bf5c3306b0808504bb8a832b4c08..dc1124a6648c4659199aa5ecc6cf152c0d9ccdc1 100644 --- a/test/Identity.FunctionalTests/LoginTests.cs +++ b/test/Identity.FunctionalTests/LoginTests.cs @@ -362,7 +362,7 @@ namespace Microsoft.AspNetCore.Identity.FunctionalTests } [Fact] - public async Task UserLockedOut_AfterMaxFailedAccessAttempts_WithGlobalAuthorizeFilter() + public async Task UserNotLockedOut_AfterMaxFailedAccessAttempts_WithGlobalAuthorizeFilter() { // Arrange var emailSender = new ContosoEmailSender(); @@ -383,7 +383,7 @@ namespace Microsoft.AspNetCore.Identity.FunctionalTests await UserStories.ConfirmEmailAsync(registrationEmail, client); // Act & Assert - await UserStories.LockoutExistingUserAsync(newClient, userName, wrongPassword); + await UserStories.LoginFailsWithWrongPasswordAsync(newClient, userName, wrongPassword); } } } diff --git a/test/Identity.FunctionalTests/Pages/Account/Login.cs b/test/Identity.FunctionalTests/Pages/Account/Login.cs index 2206c278a5ca6528b91f9da0c7e26eafb93ec3b6..044be3b06659744b98749fd5c9ca3e640c9b833b 100644 --- a/test/Identity.FunctionalTests/Pages/Account/Login.cs +++ b/test/Identity.FunctionalTests/Pages/Account/Login.cs @@ -64,6 +64,15 @@ namespace Microsoft.AspNetCore.Identity.FunctionalTests.Account 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) { var loginAttempt = await SendLoginForm(userName, password); diff --git a/test/Identity.FunctionalTests/UserStories.cs b/test/Identity.FunctionalTests/UserStories.cs index c0ff1666d2c66f23c3db061683d57386440eabe8..92111a8d2d5481062cf9d7ef8607d7180f09db97 100644 --- a/test/Identity.FunctionalTests/UserStories.cs +++ b/test/Identity.FunctionalTests/UserStories.cs @@ -36,6 +36,15 @@ namespace Microsoft.AspNetCore.Identity.FunctionalTests 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) { var index = await Index.CreateAsync(client);