public String getAlterarSenhaMsg(String login) { CredenciadoBus credenciadoBus = new CredenciadoBus(new CredenciadoValidar()); return(credenciadoBus.AlterarSenhaMensagem(login)); }
public ActionResult LogOn(string login, string senha, bool?alterarSenha, string novaSenha, string confirmarNovaSenha, string returnUrl, bool?esqueciSenha, bool?verificarTrocarSenha, string email, string cpf) { LogonVM viewModel = new LogonVM() { AlterarSenha = alterarSenha ?? false, EsqueciSenha = esqueciSenha }; viewModel.IsAjaxRequest = Request.IsAjaxRequest(); if (esqueciSenha == true) { viewModel.AlterarSenhaMsg = "Será gerada nova chave de validação que lhe permitirá restabelecer o acesso ao sistema. A chave será enviada ao e-mail registrado no seu cadastro do SIMLAM."; if (Request.IsAjaxRequest()) { return(this.getAjaxLogOnPartial()); } return(View(viewModel)); } if (verificarTrocarSenha == true) { viewModel = RecuperarSenha(viewModel, cpf, email); return(View(viewModel)); } try { string strSessionId = null; if (!GerenciarAutenticacao.ValidarLogOn(login, senha, out strSessionId)) { if (Request.IsAjaxRequest()) { return(this.getAjaxLogOnPartial()); } return(View(viewModel)); } CredenciadoBus credenciadoBus = new CredenciadoBus(new CredenciadoValidar()); string alterarSenhaMsg = credenciadoBus.AlterarSenhaMensagem(login); if (!String.IsNullOrEmpty(alterarSenhaMsg)) { Validacao.Erros.Clear(); if (!viewModel.AlterarSenha || !credenciadoBus.AlterarSenha(login, senha, novaSenha, confirmarNovaSenha)) { viewModel = new LogonVM() { AlterarSenha = true, AlterarSenhaMsg = alterarSenhaMsg }; if (Request.IsAjaxRequest()) { return(this.getAjaxLogOnPartial()); } return(View(viewModel)); } } this.formsAuthenticationService.SetAuthCookie(login, true); FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, login, DateTime.Now, DateTime.Now.Add(FormsAuthentication.Timeout), true, strSessionId); HttpCookie cookie = null; String cookieName = this.formsAuthenticationService.FormsCookieName; if (cookieName != null) { cookie = Request.Cookies[cookieName]; } if (cookie != null) { cookie.Value = this.formsAuthenticationService.Encrypt(ticket); } GerenciarAutenticacao.CarregarUser(login); BusMenu.Menu = null; if (Request.IsAjaxRequest()) { return(PartialView("LogOnPartial", new LogonVM() { IsAjaxRequest = Request.IsAjaxRequest() })); } if (!String.IsNullOrEmpty(returnUrl)) { return(Redirect(Validacao.QueryParamSerializer(HttpUtility.UrlDecode(returnUrl)))); } return(RedirectToAction("Index", "Home", Validacao.QueryParamSerializer()) as RedirectToRouteResult);; } catch (Exception exc) { Validacao.AddErro(exc); } if (Request.IsAjaxRequest()) { return(RedirectToAction("Index", "Home", Validacao.QueryParamSerializer())); } return(View(viewModel)); }
public ActionResult LogOn(string login, string senha, bool?alterarSenha, string novaSenha, string confirmarNovaSenha, string returnUrl) { LogonVM viewModel = new LogonVM() { AlterarSenha = alterarSenha ?? false }; viewModel.IsAjaxRequest = Request.IsAjaxRequest(); try { string strSessionId = null; if (!GerenciarAutenticacao.ValidarLogOn(login, senha, out strSessionId)) { if (Request.IsAjaxRequest()) { return(PartialView("LogOnPartial", new LogonVM() { IsAjaxRequest = Request.IsAjaxRequest() })); } else { return(View(viewModel)); } } CredenciadoBus credenciadoBus = new CredenciadoBus(new CredenciadoValidar()); string alterarSenhaMsg = credenciadoBus.AlterarSenhaMensagem(login); if (!String.IsNullOrEmpty(alterarSenhaMsg)) { Validacao.Erros.Clear(); if (!viewModel.AlterarSenha || !credenciadoBus.AlterarSenha(login, senha, novaSenha, confirmarNovaSenha)) { viewModel = new LogonVM() { AlterarSenha = true, AlterarSenhaMsg = alterarSenhaMsg }; if (Request.IsAjaxRequest()) { return(PartialView("LogOnPartial", new LogonVM() { IsAjaxRequest = Request.IsAjaxRequest() })); } else { return(View(viewModel)); } } } FormsAuthentication.SetAuthCookie(login, true); FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, login, DateTime.Now, DateTime.Now.Add(FormsAuthentication.Timeout), true, strSessionId); HttpCookie cookie = Request.Cookies[FormsAuthentication.FormsCookieName]; cookie.Value = FormsAuthentication.Encrypt(ticket); GerenciarAutenticacao.CarregarUser(login); BusMenu.Menu = null; if (Request.IsAjaxRequest()) { return(PartialView("LogOnPartial", new LogonVM() { IsAjaxRequest = Request.IsAjaxRequest() })); } else if (!String.IsNullOrEmpty(returnUrl)) { return(Redirect(Validacao.QueryParamSerializer(HttpUtility.UrlDecode(returnUrl)))); } else { return(RedirectToAction("Index", "Home", Validacao.QueryParamSerializer())); } } catch (Exception exc) { Validacao.AddErro(exc); } if (Request.IsAjaxRequest()) { return(RedirectToAction("Index", "Home", Validacao.QueryParamSerializer())); } else { return(View(viewModel)); } }