Reputation: 237
Hi I have been using Indentity 2.0 or a previous version, but I am wondering on ways to split the username and Email ? At the moment it only logs in depending on Username how do I switch this so the username is separate to the login ?
Currently it uses:
var user = await UserManager.FindAsync(model.Email, model.Password);
then uses SignInASync, but how do I change this to work with email ? Although it says FindASync model.Email ( it still only gets the correct user via the username) if I rename the username - different to the email, I cant login.
Upvotes: 1
Views: 650
Reputation: 35106
UserManager.FindAsync
method is taking username and password. It only happens that in the default template from VS2013 email is used as a username. Don't be fooled by this, just change your user-registration process, so they can supply username along with email and create new users with provided username and email.
After that new users will be able to login with usernames, not emails. As a transition it is recommended to allow users to login via username or email (for users who registered only with email).
Upvotes: 1