예제 #1
0
        public void ManageController_ChangePassword_Test02()
        {
            // Initialization
            ManageController ctl = new ManageController();
            ChangePasswordViewModel model = new ChangePasswordViewModel();

            // To test if it is null
            var result = ctl.ChangePassword(model);
            Assert.IsNotNull(result);
        }
예제 #2
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 users = await UserManager.FindByIdAsync(User.Identity.GetUserId());
         if (users != null)
         {
             await SignInManager.SignInAsync(users, isPersistent: false, rememberBrowser: false);
         }
         return RedirectToAction("Index", new { Message = ManageMessageId.ChangePasswordSuccess });
     }
     AddErrors(result);
     return View(model);
 }