public ActionResult ChangePassword(AccountChangePasswordViewModel model)
        {
            if (ModelState.IsValid) {
                if (_authenticationService.ChangePassword(User.Identity.Name, model.OldPassword, model.NewPassword)) {
                    return RedirectToAction("ChangePasswordSuccess");
                }

                ModelState.AddModelError("", "The current password is incorrect or the new password is invalid.");
            }

            // If we got this far, something failed, redisplay form
            ViewBag.PasswordLength = _authenticationService.MinPasswordLength;
            return View(model);
        }
        public void Changes_password_when_provided_with_correct_old_password()
        {
            const string newPassword = "******";
            var user = _authenticationService.User;

            var viewModel = new AccountChangePasswordViewModel
                                {
                                    OldPassword = user.Password,
                                    NewPassword = newPassword,
                                    ConfirmPassword = newPassword
                                };

            Assert.AreNotEqual(newPassword, user.Password);

            _accountController.ChangePassword(viewModel);

            user = _authenticationService.User;
            Assert.AreEqual(newPassword, user.Password);
        }