Skip to content
代码片段 群组 项目
未验证 提交 ee8e882d 编辑于 作者: Hao Kung's avatar Hao Kung 提交者: GitHub
浏览文件

Merge pull request #2007 from aspnet/haok/login

Fix login.cshtml
No related branches found
No related tags found
无相关合并请求
...@@ -83,7 +83,7 @@ namespace Microsoft.AspNetCore.Identity.UI.Pages.Account.Internal ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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);
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册