aspnetcore icon indicating copy to clipboard operation
aspnetcore copied to clipboard

Identity login uses PasswordSignInAsync with Input.Email as username so username and email of account need to be the same

Open erxbout opened this issue 3 years ago • 9 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Describe the bug

https://github.com/dotnet/aspnetcore/blob/afeab33afa4d81d3799dd665d6c1f47618815791/src/Identity/UI/src/Areas/Identity/Pages/V5/Account/Login.cshtml.cs#L130

This line above uses the Input.Email for logging in, but the PasswordSignInAsync method expects a username, therefore can not login if the username differs from the email..

Expected Behavior

After using the libraries with default configuration one should be able to login without scaffolding Login.cshtml.cs because this call is used wrongly..

Steps To Reproduce

  • Use libraries with default configuration
  • Add users with username and email (example user: foo, email: [email protected]) Outcome in usertable: username = foo, NormalizedUsername = FOO, email = [email protected], NormalizedEmail = [email protected]
  • Try to login with email

Exceptions (if any)

No response

.NET Version

6

Anything else?

Possible solutions are (in my opinion, maybe I miss something)

  • Edit PasswordSignInAsync to allow an email as first parameter
  • Edit PasswordSignInAsync to find user by email or by username
  • Use UserManager to select the user by email and pass it to PasswordSignInAsync correctly

Since this would be a small change (at least as far as I can see), I would volunteer to provide a PR, but I need to know which solution would be appreciated ;)

Also I do not know what DotnetVersion I should provide (I am currently using 6 but this bug might affect versions below too) Have a nice day :D

erxbout avatar Oct 20 '22 12:10 erxbout