Example #1
0
        public ViewResult Login_update(LoginViewModel model)
        {
            int             _id           = 0;
            Sistema_bll     sistema_Class = new Sistema_bll(_connection);
            string          sLogin        = Session["hashfname"].ToString();
            TAcessoFunction tacesso_Class = new TAcessoFunction();
            string          _oldPwd       = "";

            if (Session["hashfunc"].ToString() == "S")
            {
                _oldPwd = tacesso_Class.DecryptGTI(sistema_Class.Retorna_User_Password(Session["hashlname"].ToString()));
            }
            else
            {
                Usuario_web user = sistema_Class.Retorna_Usuario_Web(Session["hashlname"].ToString());
                _id     = user.Id;
                _oldPwd = Functions.Decrypt(user.Senha);
            }


            if (model.Senha != _oldPwd)
            {
                ViewBag.Result = "Senha atual não confere!";
            }
            else
            {
                if (Session["hashfunc"].ToString() == "N")
                {
                    Exception ex = sistema_Class.Alterar_Usuario_Web_Senha(_id, Functions.Encrypt(model.Senha2));
                    if (ex != null)
                    {
                        ViewBag.Result = "Erro, senha não alterada";
                    }
                    else
                    {
                        ViewBag.Result = "Sua senha foi alterada, por favor efetue login novamente";
                        return(View("sysMenu"));
                    }
                }
                else
                {
                    Usuario reg = new Usuario {
                        Nomelogin = Session["hashlname"].ToString(),
                        Senha     = tacesso_Class.Encrypt128(model.Senha2)
                    };
                    Exception ex = sistema_Class.Alterar_Senha(reg);
                    if (ex != null)
                    {
                        ViewBag.Result = "Erro, senha não alterada";
                    }
                    else
                    {
                        ViewBag.Result = "Sua senha foi alterada, por favor efetue login novamente";
                    }
                }
            }
            return(View(model));
        }
Example #2
0
 private void GravarButton_Click(object sender, EventArgs e)
 {
     if (String.IsNullOrEmpty(Pwd1Text.Text) || String.IsNullOrEmpty(Pwd2Text.Text))
     {
         MessageBox.Show("Digite a nova senha e confirme a senha.", "Erro de gravação", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else
     {
         if (string.Compare(Pwd1Text.Text, Pwd2Text.Text) != 0)
         {
             MessageBox.Show("Confirmação da senha diferente da senha digitada.", "Erro de gravação", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         else
         {
             if (Pwd1Text.Text.Length < 6)
             {
                 MessageBox.Show("Senha deve ter no mínimo 6 caracteres.", "Informação", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
             else
             {
                 string          _connection       = gtiCore.Connection_Name();
                 Sistema_bll     sistemaRepository = new Sistema_bll(_connection);
                 string          sPwd     = sistemaRepository.Retorna_User_Password(LoginText.Text);
                 TAcessoFunction _tAcesso = new TAcessoFunction();
                 if (!string.IsNullOrEmpty(sPwd) && _tAcesso.DecryptGTI(sPwd) != PwdText.Text)
                 {
                     MessageBox.Show("Senha atual inválida!", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 }
                 else
                 {
                     GTI_Models.Models.Usuario reg = new GTI_Models.Models.Usuario {
                         Nomelogin = LoginText.Text.ToUpper(),
                         Senha     = _tAcesso.Encrypt128(Pwd1Text.Text)
                     };
                     Exception ex = sistemaRepository.Alterar_Senha(reg);
                     if (ex != null)
                     {
                         ErrorBox eBox = new ErrorBox("Atenção", "Erro ao gravar nova senha.", ex);
                         eBox.ShowDialog();
                     }
                     else
                     {
                         MessageBox.Show("Senha alterada.", "Informação", MessageBoxButtons.OK, MessageBoxIcon.Information);
                         LoginText.Enabled   = true;
                         SenhaButton.Enabled = true;
                         LoginButton.Enabled = true;
                         SairButton.Enabled  = true;
                         PwdText.Text        = Pwd1Text.Text;
                         this.Size           = new Size(this.Size.Width, OriginSize);
                     }
                 }
             }
         }
     }
 }
Example #3
0
 protected void OKButton_Click(object sender, EventArgs e)
 {
     if (SenhaAtual.Text.Trim() == "" || NovaSenha.Text.Trim() == "" || Confirmacao.Text.Trim() == "")
     {
         lblMsg.Text = "Preencha todos os campos!";
     }
     else
     {
         Sistema_bll     sistema_Class = new Sistema_bll("GTIconnection");
         TAcessoFunction tacesso_Class = new TAcessoFunction();
         string          _oldPwd       = tacesso_Class.DecryptGTI(sistema_Class.Retorna_User_Password(gtiCore.pUserLoginName));
         if (SenhaAtual.Text != _oldPwd)
         {
             lblMsg.Text = "Senha atual não confere!";
         }
         else
         {
             if (NovaSenha.Text != Confirmacao.Text)
             {
                 lblMsg.Text = "Nova senha e a confirmação de senha são diferentes!";
             }
             else
             {
                 Usuario reg = new Usuario {
                     Nomelogin = gtiCore.pUserLoginName,
                     Senha     = tacesso_Class.Encrypt128(NovaSenha.Text)
                 };
                 Exception ex = sistema_Class.Alterar_Senha(reg);
                 if (ex != null)
                 {
                     lblMsg.Text = "Erro, senha não alterada";
                 }
                 else
                 {
                     gtiCore.pUserId    = 0;
                     Session["pUserId"] = 0;
                     ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "MsgChange();", true);
                     Response.Redirect("Login.aspx");
                 }
             }
         }
     }
 }