Ejemplo n.º 1
0
        public string GerarNovaSenha(string email)
        {
            WorkLifetimeManager.Value.BeginTransaction(IsolationLevel.Serializable);

            try
            {
                if (string.IsNullOrEmpty(email))
                {
                    throw new InvalidOperationException("É necessário informar seu e-mail.");
                }

                var usuario = UsuarioRepositorio.ObterPorEmail(WorkLifetimeManager.Value, email);
                if (usuario == null)
                {
                    throw new InvalidOperationException("E-mail incorreto. Verifique e tente novamente.");
                }

                var senhaAleatoria  = new GeradorSenha().Gerar();
                var senhaCodificada = Convert.ToBase64String(new SHA512Managed().ComputeHash(Encoding.ASCII.GetBytes(senhaAleatoria)));

                usuario.Senha = senhaCodificada;
                usuario.DeveDefinirNovaSenha = true;

                UsuarioRepositorio.Salvar(WorkLifetimeManager.Value, usuario);
                WorkLifetimeManager.Value.Commit();

                return(string.Format("Sua senha temporária é: {0} ", senhaAleatoria));
            }
            catch (Exception ex)
            {
                WorkLifetimeManager.Value.Rollback();
                return(ex.Message);
            }
        }
Ejemplo n.º 2
0
 public BuilderParticipante()
 {
     geradorEmail      = new GeradorEmail();
     geradorNascimento = new GeradorNascimento();
     geradorNome       = new GeradorNome();
     geradorTelefone   = new GeradorTelefone();
     geradorSenha      = new GeradorSenha();
     geradorCampus     = new GeradorCampus();
 }