Esempio n. 1
0
 private void AddErrors(MyIdentityResult result)
 {
     foreach (var error in result.Errors)
     {
         ModelState.AddModelError("", error);
     }
 }
Esempio n. 2
0
        public async Task <ActionResult> ResetPassword(ResetPasswordViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = await UserManager.FindByNameAsync(model.Email);

                if (user == null)
                {
                    ModelState.AddModelError("", "No user found.");
                    return(View());
                }
                MyIdentityResult result = await UserManager.ResetPasswordAsync(user.Id, model.Code, model.Password);

                if (result.IsSucceeded)
                {
                    return(RedirectToAction("ResetPasswordConfirmation", "Account"));
                }
                else
                {
                    AddErrors(result);
                    return(View());
                }
            }

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