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("ResetPasswordConfirmation", "Account");
     }
     var result = await UserManager.ResetPasswordAsync(user.Id, model.Code, model.Password);
     if (result.Succeeded)
     {
         return RedirectToAction("ResetPasswordConfirmation", "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)
     {
         // Не показывать, что пользователь не существует
         return RedirectToAction("ResetPasswordConfirmation", "Account");
     }
     var result = await UserManager.ResetPasswordAsync(user.Id, model.Code, model.Password);
     if (result.Succeeded)
     {
         return RedirectToAction("ResetPasswordConfirmation", "Account");
     }
     AddErrors(result);
     return View();
 }
Example #3
0
 public async Task<ActionResult> ResetPassword(ResetPasswordViewModel model)
 {
     if (!ModelState.IsValid)
     {
         return View(model);
     }
     var user = userRepository.GetByName(model.Email);
     if (user == null)
     {
         // Don't reveal that the user does not exist
         return RedirectToAction("ResetPasswordConfirmation", "Account");
     }
     user.PasswordHash = passwordHasher.HashPassword(model.Password);
     userRepository.SaveOrUpdate(user);
     return RedirectToAction("ResetPasswordConfirmation", "Account");
 }
 public async Task<ActionResult> ResetPassword(ResetPasswordViewModel model)
 {
     if (!ModelState.IsValid)
     {
         return View(model);
     }
     var user = await UserManager.FindByNameAsync(model.Email);
     if (user == null)
     {
         // Ne révélez pas que l'utilisateur n'existe pas
         return RedirectToAction("ResetPasswordConfirmation", "Account");
     }
     var result = await UserManager.ResetPasswordAsync(user.Id, model.Code, model.Password);
     if (result.Succeeded)
     {
         return RedirectToAction("ResetPasswordConfirmation", "Account");
     }
     AddErrors(result);
     return View();
 }
        public async Task<ActionResult> ResetPassword(ResetPasswordViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = await UserManager.FindByEmailAsync(model.Email);
                if (user == null)
                {
                    ModelState.AddModelError("", "No user found.");
                    return View();
                }
                IdentityResult result = await UserManager.ResetPasswordAsync(user.Id, model.Code, model.Password);
                if (result.Succeeded)
                {
                    return RedirectToAction("ResetPasswordConfirmation", "Authentication");
                }
                else
                {
                    AddErrors(result);
                    return View();
                }
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }