Why ASP.NET Core MVC 3.1 project wont let me sign in with a register user using Identity

wrabarias

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();
}
Rena

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:

enter image description here 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.

edited at
0

Comments

0 comments
Login to comment

Related

Why sign-in a new user when using ASP.NET Core Identity and token-based auth?

How to sign out other user in ASP.NET Core Identity

ASP.net Core Identity Sign in as another user from Administrator

How does Identity work in project template with Individual user account for ASP.NET Core MVC 3.1?

Identity in ASP.NET MVC Framework using Identity Core

Log IP of signed in user with ASP.net core Identity MVC

Problems adding Identity to ASP.NET Core project using EntityFrameworkCore

How to register middle-ware for a Custom Asp.Net Identity Storage Provider using ASP-5 / MVC-6 / Identity 3

Problem running project after Identity scaffolding in ASP.NET Core MVC project on Linux

Users Roles Permissions using ASP.NET Core Identity 3

UserManager CheckPassword() rehash the password in .net core 3.1 and can't sign in from asp.net MVC Project

How add ASP.NET Core identity to existing Core mvc project?

ASP.NET Core MVC MySQL Identity

ASP.NET Core Identity user groups

Using ASP.NET Identity in an ASP.NET Core MVC application without Entity Framework and Migrations

Register and Login by Phone Number in Asp.net Core Identity

Single Sign On with ASP.NET MVC 5 Identity

Can I use two ASP.NET Core Identity in one project MVC?

How can I scaffold all identity files into an ASP.NET Core 2.1 MVC project via dotnet?

change identity routing in asp.net core 3.1 from Identity/Account/Register to /Register

Google sign-in provider without ASP.NET Core Identity

ASP.net Identity 2.0 Sign-out another user

ASP.NET Core 3: Cannot resolve scoped service 'Microsoft.AspNetCore.Identity.UserManager`1[Alpha.Models.Identity.User]' from root provider

Why won't Bootstrap let me set margins on dropdowns in ASP.NET MVC page?

ASP.NET Core 2.2 MVC - Identity - Where to put custom user class?

User.Identity.Name returns null in ASP.NET Core MVC application

Why is ASP.NET Core Identity 2.0 Authorize filter causing me to get a 404?

Why sign in following Change Password in ASP.Net Core 2 MVC

How can I have multiple Identity user types when using ASP.NET Core Identity and Entity Framework Core?