public ActionResult ResetWithSecret(PasswordResetInputModel model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var account = this.userAccountService.GetByEmail(model.Email);
                    if (account != null)
                    {
                        var vm = new PasswordResetWithSecretInputModel(account.ID);
                        vm.Questions =
                            account.PasswordResetSecrets.Select(
                                x => new PasswordResetSecretViewModel
                                {
                                    QuestionID = x.ID,
                                    Question = x.Question
                                }).ToArray();

                        return View("ResetWithQuestions", vm);
                    }
                    else
                    {
                        ModelState.AddModelError("", "Invalid email");
                    }
                }
                catch (ValidationException ex)
                {
                    ModelState.AddModelError("", ex.Message);
                }
            }
            return View("ResetWithSecret");
        }
コード例 #2
0
 public ActionResult Index(PasswordResetInputModel model)
 {
     if (ModelState.IsValid)
     {
         try
         {
             this.userAccountService.ResetPassword(model.Email);
             return View("ResetSuccess");
         }
         catch (ValidationException ex)
         {
             ModelState.AddModelError("", ex.Message);
         }
     }
     return View();
 }
 public ActionResult Index(PasswordResetInputModel model)
 {
     if (ModelState.IsValid)
     {
         try
         {
             if (this.userAccountService.ResetPassword(model.Email))
             {
                 return View("ResetSuccess");
             }
             else
             {
                 ModelState.AddModelError("", "Error resetting password. The email might be invalid.");
             }
         }
         catch (ValidationException ex)
         {
             ModelState.AddModelError("", ex.Message);
         }
     }
     return View();
 }