/// <summary> /// Send the new password. /// </summary> /// <param name="model">The model.</param> /// <param name="newPass">The new pass.</param> /// <returns></returns> public static Boolean SendNewPassword(Usuario model, String newPass, Boolean isAdminPortal = true) { var ret = false; try { String errorMessage; var cids = CidLogo; var imagens = Logo; var bodyHTML = WebHelpers.ScreenScrapeHtml(HttpContext.Current.Server.MapPath(Settings.UrlTemplateChangePassword)); // Replace dos Textos Padrões bodyHTML = DefineResources(bodyHTML); bodyHTML = bodyHTML.Replace("[NOME]", model.NomeUsuario); bodyHTML = bodyHTML.Replace("[MENSAGEM]", isAdminPortal ? Resources.Resource.Email_NovaSenha : Resources.Resource.Email_NovaSenha_Ecommerce); bodyHTML = bodyHTML.Replace("[LOGIN]", model.Login); bodyHTML = bodyHTML.Replace("[SENHA]", newPass); ret = WebHelpers.SendMailWithImages(String.Empty, Settings.TitleSite, model.Email, Resource.Email_ConfirmacaoSenha_Assunto, bodyHTML, cids, imagens, null, // smtp.NetWork.Settings out errorMessage); if (!ret) { LogService.Log("EmailService.SendNewPassword()", String.Format("{0} Email [{1}]", errorMessage, model.Email), Model.Enum.TipoLog.Erro); } else // Grava Log de Segurança { LogService.Log(String.Format("Email.SendNewPassword({0})", model.Email), Resource.Msg_Log_SenhaAlterada, Model.Enum.TipoLog.Seguranca); } } catch (Exception ex) { LogService.Log("Email.SendNewPassword()", ex); } return ret; }
/// <summary> /// Create a new Usuario object. /// </summary> /// <param name="idUsuario">Initial value of the IdUsuario property.</param> /// <param name="nomeUsuario">Initial value of the NomeUsuario property.</param> /// <param name="dataInclusao">Initial value of the DataInclusao property.</param> /// <param name="email">Initial value of the Email property.</param> /// <param name="login">Initial value of the Login property.</param> /// <param name="senha">Initial value of the Senha property.</param> /// <param name="isAtivo">Initial value of the IsAtivo property.</param> /// <param name="isPrimeiroAcesso">Initial value of the IsPrimeiroAcesso property.</param> public static Usuario CreateUsuario(global::System.Int32 idUsuario, global::System.String nomeUsuario, global::System.DateTime dataInclusao, global::System.String email, global::System.String login, global::System.String senha, global::System.Boolean isAtivo, global::System.Boolean isPrimeiroAcesso) { Usuario usuario = new Usuario(); usuario.IdUsuario = idUsuario; usuario.NomeUsuario = nomeUsuario; usuario.DataInclusao = dataInclusao; usuario.Email = email; usuario.Login = login; usuario.Senha = senha; usuario.IsAtivo = isAtivo; usuario.IsPrimeiroAcesso = isPrimeiroAcesso; return usuario; }
/// <summary> /// Deprecated Method for adding a new object to the Usuario EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToUsuario(Usuario usuario) { base.AddObject("Usuario", usuario); }
public ActionResult GerarNovaSenha(int? idCliente, String emailTemp) { var regExpEmail = new Regex(@"^[\w-]+(\.[\w-]+)*@([a-z0-9-]+(\.[a-z0-9-]+)*?\.[a-z]{2,6}|(\d{1,3}\.){3}\d{1,3})(:\d{4})?$"); if (!regExpEmail.IsMatch(emailTemp) && !String.IsNullOrWhiteSpace(emailTemp)) { return Json(new JsonRequestResult { ResultType = JsonRequestResultType.Alert, Message = Resources.Resource.Conta_EmailInvalido }); } var model = new Usuario(); if (idCliente != null) { var cliente = new ClienteService().GetById(idCliente.Value); if (cliente != null) { model = cliente.Usuario; } } if (!String.IsNullOrWhiteSpace(emailTemp)) { model.Email = emailTemp; } if (ModelState.IsValid) { var newPass = Membership.GeneratePassword(6, 2); if (Email.SendNewPassword(model, newPass, false)) { model.Senha = newPass; model.LembreteSenha = String.Format(Resources.Resource.Senha_PerguntaSecreta, DateTime.Now); new UsuarioService().UpdateObject(model); return Json(new JsonRequestResult { ResultType = JsonRequestResultType.Success, Message = Resources.Resource.Conta_SenhaEncaminhadaEmail }, JsonRequestBehavior.AllowGet); } return Json(new JsonRequestResult { ResultType = JsonRequestResultType.Error, Message = Resources.Resource.Autenticacao_RecuperarSenhaErro }, JsonRequestBehavior.AllowGet); } return Json(new JsonRequestResult { ResultType = JsonRequestResultType.Error, Message = Resources.Resource.Msg_Geral_Erro }, JsonRequestBehavior.AllowGet); }