Inheritance: PasswordViewModel
Exemplo n.º 1
0
 public async Task<ActionResult> ChangePassword(ChangePasswordViewModel model)
 {
     if (!ModelState.IsValid)
     {
         return View(model);
     }
     var result = await UserManager.ChangePasswordAsync(User.Identity.GetUserId(), model.OldPassword, model.NewPassword);
     if (result.Succeeded)
     {
         var user = await UserManager.FindByIdAsync(User.Identity.GetUserId());
         if (user != null)
         {
             await SignInAsync(user, isPersistent: false);
         }
         return RedirectToAction("Index", new { Message = ManageMessageId.ChangePasswordSuccess });
     }
     AddErrors(result);
     return View(model);
 }
Exemplo n.º 2
0
 public virtual async Task<ActionResult> ChangePassword(ChangePasswordViewModel model)
 {
     var parentViewModel = GetBaseManageAccountViewModel();
     parentViewModel.PasswordViewModel = model;
     if (!ModelState.IsValid)
     {
         return RedirectToAction("Manage", new { Message = ManageMessageId.ErrorEnterEmail });
     }
     var result = await userManager.ChangePasswordAsync(User.Identity.GetUserId(), model.OldPassword, model.NewPassword);
     if (result.Succeeded)
     {
         return RedirectToAction("Manage", new { Message = ManageMessageId.ChangePasswordSuccess });
     }
     SetViewBag();
     AddErrors(result, "password");
     return View("Manage", parentViewModel);
 }