asp.net mvc - Why does SignInManager fetch the user twice on login? -
when supplying username signinmanager.passwordsigninasync()
first calls findbynameasync()
calls findbyidasync()
. implemented custom userstore, don't understand why calls both, making 2 database calls? seems unnecessary overhead.
in both cases i'm returning same iuser object different criteria. i'm supposed do?
public task<myappidentityuser> findbyidasync(long userid) { task<myappidentityuser> task = _db.profile.where(x => x.userid == userid) .select(x => new myappidentityuser { id = x.userid, username = x.username }) .firstordefaultasync(); return task; } public task<myappidentityuser> findbynameasync(string username) { task<myappidentityuser> task = _db.profile.where(x => x.username == username) .select(x => new myappidentityuser { id = x.userid, username = x.username }) .firstordefaultasync(); return task; }
additional - noticed there's 3rd , 4th query getpasswordhashasync() , getlockoutenabledasync(). why of these calls necessary , can't bundled in single call?
so figured out after head scratching. when calling signinmanager.passwordsigninasync()
string username , password, first queries db iuser object id key db (source code). calls again iuser object several checks call getuseridasync()
on , on again, despite manager having it. don't know why out of box.
Comments
Post a Comment