Ejemplo n.º 1
0
        public ActionResult ChangePassword(ChangePasswordModel model)
        {
            var userid = UserAccountHelper.GetUser(HttpContext.User.Identity.Name).UserProfileID;
            var oldpassword = _userService.HashPassword(model.OldPassword);
            if (ModelState.IsValid)
            {
                bool changePasswordSucceeded;

                if (_userService.GetUserDetail(userid).Password == oldpassword)
                {
                    try
                    {
                        changePasswordSucceeded = _userService.ChangePassword(userid, model.NewPassword);
                    }
                    catch (Exception e)
                    {
                        changePasswordSucceeded = false;
                        //ModelState.AddModelError("Errors", e.Message);
                    }
                    if (changePasswordSucceeded)
                        ModelState.AddModelError("Success", "Password Successfully Changed.");
                    //return RedirectToAction("ChangePasswordSuccess");
                    else
                        ModelState.AddModelError("Errors", "The new password is invalid.");

                }
                else ModelState.AddModelError("Errors", "The current password is incorrect ");
            }
            return View(model);
        }
Ejemplo n.º 2
0
 public ActionResult ChangePassword()
 {
     //var userInfo=userService.FindById(id);
     var model = new ChangePasswordModel();
     return View(model);
 }