public ActionResult UserProfile(UserProfileViewModel model) { try { if (model.CaptchaText == HttpContext.Session["captchastring"].ToString()) { ViewBag.Message = "CAPTCHA correcto!"; } else { ViewBag.Message = "CAPTCHA incorrecto!"; ModelState["CaptchaText"].Errors.Add("CAPTCHA incorrecto!"); } if (!ModelState.IsValid) { var errors = new Dictionary<string, object>(); foreach (var key in ModelState.Keys) { if (ModelState[key].Errors.Count > 0) { errors[key] = ModelState[key].Errors; } else errors[key] = ""; } ModelState.Clear(); return Json(new { success = false, errores = errors, validaciones = "", view = model }); } ModelState.Clear(); // Guardo el cambio ClsAgente agt = new ClsAgente(); if (agt.UpdateAgenteWeb(Convert.ToInt32(model.AgenteID), model.ConfirmPassword, model.Email)) { var logged = (DataSet)Session["UserObj"]; logged.Tables["catAgentes"].Rows[0]["Email"] = model.Email; logged.Tables["catAgentes"].Rows[0]["cPasww"] = model.ConfirmPassword; Session["UserObj"] = logged; Session["ChangePassword"] = null; //*cambio aqui } return PartialView(model); } catch (Exception err) { Response.StatusCode = (int)(System.Net.HttpStatusCode.InternalServerError); LogDeErrores.RegistroErrorWeb(err, DatoUsuario.idAgente, DatoUsuario.nomAgente, DatoUsuario.sIp, DatoUsuario.sHostName); return Json("ErrInterno"); } }
// GET: /Account/ResetPassword public ActionResult UserProfile() { try { var logged = (DataSet)Session["UserObj"]; var profile = new UserProfileViewModel() { AgenteID = logged.Tables["catAgentes"].Rows[0]["nAgenteID"].ToString(), AgenteName = logged.Tables["catAgentes"].Rows[0]["cNombre"].ToString(), Credencial = logged.Tables["catAgentes"].Rows[0]["cCredencial"].ToString(), Email = logged.Tables["catAgentes"].Rows[0]["Email"].ToString(), ActualPassword = logged.Tables["catAgentes"].Rows[0]["cPasww"].ToString().Trim(), OldPassword = "", PasswordHash = "", ConfirmPassword = "", }; return PartialView(profile); } catch (Exception err) { Response.StatusCode = (int)(System.Net.HttpStatusCode.InternalServerError); LogDeErrores.RegistroErrorWeb(err, DatoUsuario.idAgente, DatoUsuario.nomAgente, DatoUsuario.sIp, DatoUsuario.sHostName); return Json("ErrInterno"); } }