public JsonResponse <bool> ChangeUserPassword(UserAccountDTO user) { JsonResponse <bool> response = new JsonResponse <bool>(); try { var User = UserBusinessInstance.GetUserByEmail(user.email); if (User == null) { response.SingleResult = false; response.StatusCode = "200"; response.IsSuccess = false; response.Message = "User does not exist in our system."; return(response); } if (User.Password != user.password) { User.Password = user.password; User.UpdatedDate = DateTime.Now; response.SingleResult = SecurityBusinessInstance.ChangePassword(user.Guid, User.Password); response.IsSuccess = response.SingleResult; response.StatusCode = "200"; response.Message = "Your password has been successfully updated."; } else { response.SingleResult = false; response.StatusCode = "200"; response.IsSuccess = false; response.Message = "You can not use same password. it must be different than previous."; return(response); } } catch (Exception ex) { response.IsSuccess = false; response.StatusCode = "500"; response.Message = ex.Message; } return(response); }
public ActionResult ChangePassword(ManageUserViewModel model, FormCollection collection) { ExceptionEngine.ProcessAction(() => { //lblError.Text = ""; string uniqueid = collection["hdnUniqueID"].ToString(); String NewPassword = model.NewPassword; List <string> ErrorMessage = new List <string>(); if (model.NewPassword != model.ConfirmPassword) { ViewBag.Message = "New Password & Retype Password did not match"; ViewBag.ShowForm = true; return; } NewPassword.IsComplexPassword(ref ErrorMessage); if (ErrorMessage.Count > 0) { ViewBag.Message = ErrorMessage.Select(k => k).Aggregate((a, b) => a + "\n" + b); ViewBag.ShowForm = true; return; } else if (SecurityBusinessInstance.ChangePassword(uniqueid, NewPassword)) { ViewBag.ShowPopUp = true; ViewBag.Message = "Password Changed Successfully"; return; } else { ViewBag.ShowPopup = true; ViewBag.Message = "You are not authorized to change password."; return; } }, AspectEnums.ExceptionPolicyName.AssistingAdministrators.ToString()); return(View()); }