Skip to content

Commit 5c174a3

Browse files
committed
Fix login.cshtml
1 parent 2327d6a commit 5c174a3

File tree

4 files changed

+21
-3
lines changed

4 files changed

+21
-3
lines changed

src/UI/Areas/Identity/Pages/Account/Login.cshtml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public override async Task<IActionResult> OnPostAsync(string returnUrl = null)
8383
{
8484
// This doesn't count login failures towards account lockout
8585
// To enable password failures to trigger account lockout, set lockoutOnFailure: true
86-
var result = await _signInManager.PasswordSignInAsync(Input.Email, Input.Password, Input.RememberMe, lockoutOnFailure: true);
86+
var result = await _signInManager.PasswordSignInAsync(Input.Email, Input.Password, Input.RememberMe, lockoutOnFailure: false);
8787
if (result.Succeeded)
8888
{
8989
_logger.LogInformation("User logged in.");

test/Identity.FunctionalTests/LoginTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ void ConfigureTestServices(IServiceCollection services) =>
362362
}
363363

364364
[Fact]
365-
public async Task UserLockedOut_AfterMaxFailedAccessAttempts_WithGlobalAuthorizeFilter()
365+
public async Task UserNotLockedOut_AfterMaxFailedAccessAttempts_WithGlobalAuthorizeFilter()
366366
{
367367
// Arrange
368368
var emailSender = new ContosoEmailSender();
@@ -383,7 +383,7 @@ void ConfigureTestServices(IServiceCollection services) =>
383383
await UserStories.ConfirmEmailAsync(registrationEmail, client);
384384

385385
// Act & Assert
386-
await UserStories.LockoutExistingUserAsync(newClient, userName, wrongPassword);
386+
await UserStories.LoginFailsWithWrongPasswordAsync(newClient, userName, wrongPassword);
387387
}
388388
}
389389
}

test/Identity.FunctionalTests/Pages/Account/Login.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,15 @@ public async Task<Index> LoginValidUserAsync(string userName, string password)
6464
Context.WithAuthenticatedUser());
6565
}
6666

67+
public async Task LoginWrongPasswordAsync(string userName, string password)
68+
{
69+
var failedLogin = await SendLoginForm(userName, password);
70+
71+
ResponseAssert.IsOK(failedLogin);
72+
var content = await failedLogin.Content.ReadAsStringAsync();
73+
Assert.Contains("Invalid login attempt.", content);
74+
}
75+
6776
public async Task<DefaultUIPage> LockoutUserAsync(string userName, string password)
6877
{
6978
var loginAttempt = await SendLoginForm(userName, password);

test/Identity.FunctionalTests/UserStories.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,15 @@ internal static async Task<Index> LoginExistingUserAsync(HttpClient client, stri
3636
return await login.LoginValidUserAsync(userName, password);
3737
}
3838

39+
internal static async Task LoginFailsWithWrongPasswordAsync(HttpClient client, string userName, string password)
40+
{
41+
var index = await Index.CreateAsync(client);
42+
43+
var login = await index.ClickLoginLinkAsync();
44+
45+
await login.LoginWrongPasswordAsync(userName, password);
46+
}
47+
3948
internal static async Task<DefaultUIPage> LockoutExistingUserAsync(HttpClient client, string userName, string password)
4049
{
4150
var index = await Index.CreateAsync(client);

0 commit comments

Comments
 (0)