public ActionResult Login_reset(LoginViewModel model) { //if (Session["hashid"] == null) { // Functions.pUserFullName = "Visitante"; // return View(model); //} var response = Request["g-recaptcha-response"]; var client = new WebClient(); string secretKey = "6LfRjG0aAAAAACH5nVGFkotzXTQW_V8qpKzUTqZV"; var result = client.DownloadString(string.Format("https://www.google.com/recaptcha/api/siteverify?secret={0}&response={1}", secretKey, response)); var obj = JObject.Parse(result); var status = (bool)obj.SelectToken("success"); string msg = status ? "Sucesso" : "Falha"; if (!status) { ViewBag.Result = "Código Recaptcha inválido."; return(View(model)); } Sistema_bll sistemaRepository = new Sistema_bll(_connection); Usuario_web reg = sistemaRepository.Retorna_Usuario_Web(model.Email); int Id = reg.Id; Exception ex = sistemaRepository.Alterar_Usuario_Web_Senha(Id, model.Senha); ViewBag.Message = "A senha foi alterar com sucesso."; return(View(model)); }
public ActionResult User_Query(LoginViewModel model, int?ide, string tp, string action) { List <Usuario_web> Lista = new List <Usuario_web>(); Sistema_bll sistemaRepository = new Sistema_bll(_connection); if (action == "rs") { //Usuario_web _user = sistemaRepository.Retorna_Usuario_Web((int)ide); //if (!_user.Ativo) { // ViewBag.Result = "A conta não esta ativa"; // return View(model); //} else { Exception ex = sistemaRepository.Alterar_Usuario_Web_Senha((int)ide, Functions.Encrypt("123456")); // ViewBag.Result = "A senha foi reseta com sucesso"; //} model.Lista_Usuario_Web = Lista; return(Json(new { success = true, data = model }, JsonRequestBehavior.AllowGet)); } if (!string.IsNullOrEmpty(model.Filter)) { Lista = sistemaRepository.Lista_Usuario_Web(model.Filter); } model.Lista_Usuario_Web = Lista; // return Json(new { success = true, data = model }, JsonRequestBehavior.AllowGet); return(View(model)); }
public ViewResult Login_update(LoginViewModel model) { int _id = 0; Sistema_bll sistema_Class = new Sistema_bll(_connection); string sLogin = Session["hashfname"].ToString(); TAcessoFunction tacesso_Class = new TAcessoFunction(); string _oldPwd = ""; if (Session["hashfunc"].ToString() == "S") { _oldPwd = tacesso_Class.DecryptGTI(sistema_Class.Retorna_User_Password(Session["hashlname"].ToString())); } else { Usuario_web user = sistema_Class.Retorna_Usuario_Web(Session["hashlname"].ToString()); _id = user.Id; _oldPwd = Functions.Decrypt(user.Senha); } if (model.Senha != _oldPwd) { ViewBag.Result = "Senha atual não confere!"; } else { if (Session["hashfunc"].ToString() == "N") { Exception ex = sistema_Class.Alterar_Usuario_Web_Senha(_id, Functions.Encrypt(model.Senha2)); if (ex != null) { ViewBag.Result = "Erro, senha não alterada"; } else { ViewBag.Result = "Sua senha foi alterada, por favor efetue login novamente"; return(View("sysMenu")); } } else { Usuario reg = new Usuario { Nomelogin = Session["hashlname"].ToString(), Senha = tacesso_Class.Encrypt128(model.Senha2) }; Exception ex = sistema_Class.Alterar_Senha(reg); if (ex != null) { ViewBag.Result = "Erro, senha não alterada"; } else { ViewBag.Result = "Sua senha foi alterada, por favor efetue login novamente"; } } } return(View(model)); }