Пример #1
0
        public virtual async Task <ActionResult> UpgradeAccount()
        {
            var user = await UserManager.FindByIdAsync(HttpContext.User.Identity.GetUserId());

            var model = new UpgradeAccountModel()
            {
                CurrentUser = user
            };

            return(View(model));
        }
Пример #2
0
        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"));
        }