/// <summary> /// Change Password Popup /// </summary> /// <returns></returns> public ActionResult ChangePassword() { int[] regvia = { (int)RegisterVia.Android, (int)RegisterVia.Website, (int)RegisterVia.IPhone }; if (!regvia.Contains(LOGGEDIN_USER.RegisterVia)) return Json(new ActionOutput { Message = "Password can not be changed for facebook user", Status = ActionStatus.Error }, JsonRequestBehavior.AllowGet); ChangePasswordWebsiteModel model = new ChangePasswordWebsiteModel(); PopupModel popup = new PopupModel(); popup.Title = "Change Password"; popup.Body = RenderRazorViewToString("_ChangePassword", model); string popupString = RenderRazorViewToString("_LayoutPopup", popup); return Json(new ActionOutput { Results = new List<string> { popupString }, Status = ActionStatus.Successfull }, JsonRequestBehavior.AllowGet); }
ActionOutput IUserManager.UpdatePassword(ChangePasswordWebsiteModel model, int UserID) { byte[] pass = Utility.GetEncryptedValue(model.OldPassword); var user = Context.Users.Where(m => m.UserID == UserID && m.Password == pass).FirstOrDefault(); if (user == null) return new ActionOutput { Status = ActionStatus.Error, Message = "Old password is incorrect!!!" }; user.Password = Utility.GetEncryptedValue(model.Password); SaveChanges(); return new ActionOutput { Status = ActionStatus.Successfull, Message = "Password has been changed." }; }
/// <summary> /// Change User Password /// </summary> /// <param name="model"></param> /// <returns></returns> public ActionResult UpdatePassword(ChangePasswordWebsiteModel model) { return Json(_userManager.UpdatePassword(model, LOGGEDIN_USER.UserID), JsonRequestBehavior.AllowGet); }