I have scaffolded the Login View to create my own, but the thing is that whenever I tried to Login to the application an invalid login attempt error appears as if it is not finding the user. Cant seem to find a solution to this. Can someone help me please!!!
This is the code I'm using and it was autogenerated:
var result = await _signInManager.PasswordSignInAsync(user.UserName, Input.Password, Input.RememberMe, lockoutOnFailure: false);
if (result.Succeeded)
{
_logger.LogInformation("User logged in.");
return LocalRedirect(returnUrl);
}
if (result.RequiresTwoFactor)
{
return RedirectToPage("./LoginWith2fa", new { ReturnUrl = returnUrl, RememberMe = Input.RememberMe });
}
if (result.IsLockedOut)
{
_logger.LogWarning("User account locked out.");
return RedirectToPage("./Lockout");
}
else
{
ModelState.AddModelError(string.Empty, "Invalid login attempt.");
return Page();
}
By using default scaffold Identity,I could reproduce your issue if you do not confirm your email.Here are two ways to resolve your issue.
1.You could click the following link to confirm the email like below:
2.Or you could set RequireConfirmedAccount=false
like below:
services.AddDefaultIdentity<IdentityUser>(
options => options.SignIn.RequireConfirmedAccount = false)
.AddEntityFrameworkStores<ApplicationDbContext>();
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments