Пример #1
0
        public async Task <ActionResult> ResetPassword(ResetPasswordViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            var user = await UserManager.FindByEmailAsync(model.Email);

            if (user == null)
            {
                // Don't reveal that the user does not exist
                TempData["message"] = new MessageViewModel {
                    Message = "Something went wrong.Try reseting your password again.", IsError = true
                };
                return(RedirectToAction("Login", "Account"));
            }
            var result = await UserManager.ResetPasswordAsync(user.Id, model.Code, model.Password);

            if (result.Succeeded)
            {
                TempData["message"] = new MessageViewModel {
                    Message = "Password has been updated.", IsUpdated = true
                };
                return(RedirectToAction("Login", "Account"));
            }
            AddErrors(result);
            return(View());
        }
 public async Task<ActionResult> ResetPassword(ResetPasswordViewModel model)
 {
     if (!ModelState.IsValid)
     {
         return View(model);
     }
     var user = await UserManager.FindByNameAsync(model.Email);
     if (user == null)
     {
         // Don't reveal that the user does not exist
         return RedirectToAction("Login", "Account");
     }
     var result = await UserManager.ResetPasswordAsync(user.Id, model.Code, model.Password);
     if (result.Succeeded)
     {
         TempData["message"] = new MessageViewModel { Message = "Password has been updated.", IsUpdated = true };
         return RedirectToAction("Login", "Account");
     }
     AddErrors(result);
     return View();
 }