I'm a little flummoxed by trying to implement the IPasswordStore in the new asp.net mvc 5. I want to use my own ORM.
Take this familiar code snippet from the scaffolded 'AccountController' that runs when the 'register' screen is used in the example project.
public async Task<ActionResult> Register(RegisterViewModel model)
{
if (ModelState.IsValid)
{
var user = new ApplicationUser() { UserName = model.UserName };
var result = await UserManager.CreateAsync(user, model.Password);
if (result.Succeeded)
{
await SignInAsync(user, isPersistent: false);
return RedirectToAction("Index", "Home");
}
else
{
AddErrors(result);
}
}
// If we got this far, something failed, redisplay form
return View(model);
}
the
var result = await UserManager.CreateAysnc(user, model.Password)
line first calls the IPasswordStore function
public Task SetPasswordHashAsync(TUser user, string passwordHash)
without having first called from IUserStore
public Task CreateAsync(TUser user)
How do I set the password hash if the user isn't created in the db yet? Furthermore, we actually don't even know if we can create the proposed 'user' because we haven't checked to see if the username is taken yet using
public Task<TUser> FindByNameAsync(string userNameIn)
which is called right afterwards.
Any ideas?