Merge pull request #2007 from aspnet/haok/login

Fix login.cshtml
This commit is contained in:
Hao Kung 2018-10-12 10:52:13 -07:00 committed by GitHub
commit ee8e882d17
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 3 deletions

View File

@ -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.");

View File

@ -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);
}
}
}

View File

@ -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);

View File

@ -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);