I have a custom implementation of IUserStore because I want to use my repository layer. All of my database tables stores the user’s name who inserted or last updated the row. I get user name from HttpContext.Current, which works well, except when repository is called via UserManager, I get null in HttpContext.Current. When my own business layer call the repository everything works well. (I am using async version of methods.)
Have anybody an idea what happening in UserManager, why losing current httpcontext?
I call user service from account controller:
var ir = await UserService.ChangePasswordAsync(User.Identity, vm.Password);
User service saves new password with UserManager class:
var ir = await Manager.PasswordValidator.ValidateAsync(password);
if (!ir.Succeeded)
return ir;
user.PasswordHash = Manager.PasswordHasher.HashPassword(password);
ir = await Manager.UpdateAsync(user);
UserManager uses my own implementation of UserStore:
public Task UpdateAsync(UserEntity user)
{
return UserRepo.UpdateAsync(user);
}
Here, when I stop the program with debugger, in HttpContext.Current I have null. That is a problem becouse user repository try to get curent user name.