public virtual async Task <ActionResult> UpgradeAccount() { var user = await UserManager.FindByIdAsync(HttpContext.User.Identity.GetUserId()); var model = new UpgradeAccountModel() { CurrentUser = user }; return(View(model)); }
public async Task <IActionResult> UpgradeAccount(UpgradeAccountModel model) { if (ModelState.IsValid) { var user = await userManager.GetUserAsync(HttpContext.User); if (userManager.PasswordHasher.VerifyHashedPassword(user, user.PasswordHash, model.Password) == PasswordVerificationResult.Success) { await signInManager.SignOutAsync(); await userManager.AddToRoleAsync(user, "Seller"); await signInManager.PasswordSignInAsync(user, model.Password, false, false); } } return(RedirectToAction("Index", "Home")); }