public String getAlterarSenhaMsg(String login) { FuncionarioBus credenciadoBus = new FuncionarioBus(new FuncionarioValidar()); return(credenciadoBus.AlterarSenhaMensagem(login)); }
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)); } } FuncionarioBus busFuncionario = new FuncionarioBus(new FuncionarioValidar()); string alterarSenhaMsg = busFuncionario.AlterarSenhaMensagem(login); if (!String.IsNullOrEmpty(alterarSenhaMsg)) { Validacao.Erros.Clear(); if (!viewModel.AlterarSenha || !busFuncionario.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)); } } } 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); } //Cria o cookie que é usado para a verificação periódica de E-PTVs aguardando análise. #region Insere cookie EPTV InsereCookieEPTV(); #endregion Insere cookie EPTV GerenciarAutenticacao.CarregarUser(login); BusMenu.Menu = null; //Gera a mensagem de alerta de E-PTV (se houver) #region Alerta de E-PTV var funcionario = new FuncionarioBus().ObterFuncionarioAutenticacao(login); PTVBus _busPTV = new PTVBus(); _busPTV.VerificaAlertaEPTV(funcionario.Id, login); #endregion Alerta de E-PTV 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)); } }
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)); } } FuncionarioBus busFuncionario = new FuncionarioBus(new FuncionarioValidar()); string alterarSenhaMsg = busFuncionario.AlterarSenhaMensagem(login); if (!String.IsNullOrEmpty(alterarSenhaMsg)) { Validacao.Erros.Clear(); if (!viewModel.AlterarSenha || !busFuncionario.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)); } }