Example #1
0
 /// <summary>
 /// Change password
 /// </summary>
 /// <returns>Change password view</returns>
 public ActionResult ChangePassword()
 {
     using (var dataContext = dataContextFactory.Create())
     {
         var viewModel = new ChangePasswordViewModel(dataContext.GetUser(User.Identity).Email);
         return View(viewModel);
     }
 }
Example #2
0
        public ActionResult ChangePassword(ChangePasswordViewModel model)
        {
            if (ModelState.IsValid)
            {
                if(WebSecurity.ChangePassword(User.Identity.Name, model.OldPassword, model.NewPassword))
                {
                    Flash.Success("Your password has been changed.");
                    return RedirectToAction("Index");
                }
                else
                {
                    ModelState.AddModelError("", "The current password is incorrect or the new password is invalid.");
                }
            }

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