I'm creating an web app using react. All I want to do is to change the login logic, so that a user can login with username and password instead of email. Should i use app.MapPost("api/login... and change the login logic here, or would a controller like I've done with the MVC framework be a better option? Or is there a better way that I am not aware of?
I've been reading ms Docs for a while, and I can't find anything about AccountControllers like I did a few years ago, all I can find is an old git repo, so I am starting to think that maybe this way to do things is outdated?
There's no right or wrong way of implementing an endpoint, it's really up to your preference on how to do it. Whether you're using minimal APIs or controllers.
Minimal APIs are just for simplicity, the controller pattern you've used before is still widely used, especially in bigger applications that require a more structured approach.
ASP.NET Core Identity
does have built-in minimal API endpoints that you can map. (.NET 8.0
or higher)
They are unfortunately not extensible, so in your case where you'd like to log in with a username rather than an email, you'll have to implement your own logic.
This answer to another question might be helpful when implementing your endpoints.
You can read more about the Identity APIs in the documentation or check out the source code on GitHub.
Edit: Documentation on the differences between controller-based APIs and minimal APIs.