asp.net mvc - How to login using email in identity 2? -
in mvc5 identity 2 signinmanager.passwordsigninasync take user name login.
var result = await signinmanager.passwordsigninasync(model.email, model.password, model.rememberme, shouldlockout: false);
but user name , email not same. want email address login.so how can that? thanks
get user usermanager email.
var user = usermanager.findbyemail(email);
then use signinmanager's passwordsigninasync user's username
var result = await signinmanager .passwordsigninasync(user.username,password,ispersistent,shouldlockout);
or inside signinmanager add method (asp.net identity discussion)
public async task<signinstatus> passwordemailsigninasync(string email, string password, bool ispersistent, bool shouldlockout) { var user = usermanager.findbyemail(email); return await passwordsigninasync(user.username,password,ispersistent,shouldlockout); }
then use same passwordsigninasync user email instead of usermane.
Comments
Post a Comment