private void BtnAlterarSenha_Click(object sender, RoutedEventArgs e) { String senhaAtual = txtSenhaAtual.Password.ToString(); String senhaNova = txtSenhaNova.Password.ToString(); String confSenhaNova = txtConfSenhaNova.Password.ToString(); CalculaPontuacaoSenha(senhaNova); try { if (ValidacaoUtils.SenhaValida(ModoVerificacaoSenha.Alterando, senhaNova, confSenhaNova, senhaAtual)) { _usuarioApplication.AlterarSenhaUsuario(_cpf, senhaNova); MensagemUtils.MostrarMensagemSucesso(Title, "Senha alterada com sucesso!"); Close(); } } catch (Exception ex) { MensagemUtils.MostrarMensagemAlerta(Title, ex.Message); txtSenhaAtual.Clear(); txtSenhaNova.Clear(); txtConfSenhaNova.Clear(); txtSenhaNova.Focus(); } }
public void CadastrarUsuario(string cpf, string rg, string nome, string senha, string confirmacaoSenha) { try { ValidacaoUtils.SenhaValida(ModoVerificacaoSenha.Adicionando, senha, confirmacaoSenha); } catch (Exception ex) { throw new SenhaInvalidaException(ex.Message); } if (!ValidacaoUtils.CPFValido(cpf)) { throw new CPFInvalidoException(); } if (!ValidacaoUtils.RGValido(rg)) { throw new RGInvalidoException(); } if (_usuarioRepository.GetUsuarioByCPF(cpf) != null) { throw new CPFInvalidoException("O CPF já está cadastrado!"); } if (_usuarioRepository.GetUsuarioByRG(rg) != null) { throw new RGInvalidoException("O RG já está cadastrado!"); } var statusUsuario = _statusUsuarioRepository.GetStatusUsuarioByEstadoAsync("Normal"); var perfilUsuario = _perfilUsuarioRepository.GetPerfilUsuarioByTipoAsync("Comum"); // AQUI var senhaCriptografadaParcial = CriptografiaUtils.CriptografiaEmCifra(senha); var senhaCriptografadaFinal = CriptografiaUtils.CriptografaEmCodigo(senhaCriptografadaParcial); var usuario = new Usuario(cpf, rg, nome, senhaCriptografadaFinal, DateTime.Now, statusUsuario, perfilUsuario); _usuarioRepository.AddUsuario(usuario); }