Пример #1
0
        private void tbPass_TextChanged(object sender, EventArgs e)
        {
            var clearPass = MetaBackEnd.getCorrectPass(tbPass.Text);
            var zxcvbn    = Zxcvbn.Zxcvbn.MatchPassword(clearPass);

            if (!(zxcvbn.Score > 2))
            {
                errorSign.SetError(tbPass, "Password too easy");
                isPassValid = false;
            }
            else
            {
                if (!(clearPass.Length <= 20))
                {
                    errorSign.SetError(tbPass, "Password can't contain over 20 symbols");
                    isPassValid = false;
                }
                else
                {
                    errorSign.SetError(tbPass, "");
                    isPassValid = true;
                }
            }
            SyncBtnSignUpState();
        }
Пример #2
0
 private void btnLogIn_Click(object sender, EventArgs e)
 {
     using (var ctx = new UsersContext())
     {
         var user = ctx.awp_users.SingleOrDefault(us => us.login_ == tbLogin.Text);
         if (user != default)
         {
             var bsaltCurUser = user.salt;
             var rawPass      = tbPass.Text;
             var bpassCurUser = MetaBackEnd.CalcHash(MetaBackEnd.getCorrectPass(rawPass), bsaltCurUser);
             if (user.password.SequenceEqual(bpassCurUser))
             {
                 var roleId    = ctx.specials.Find(user.id_special).id_role;
                 var roleIndex = ctx.roles.Find(roleId).id;
                 var formAwp   = new FormAWP(roleIndex);
                 Hide();
                 if (formAwp.ShowDialog() == DialogResult.Cancel)
                 {
                     MessageBox.Show("Good bye");
                 }
                 tbLogin.Text = tbPass.Text = "";
                 Show();
             }
             else
             {
                 MessageBox.Show("Your password is wrong");
             }
         }
         else
         {
             MessageBox.Show("Your login is wrong");
         }
     }
 }
Пример #3
0
        private void CheckPassword(DataGridViewCell cell)
        {
            var clearPass = MetaBackEnd.getCorrectPass(cell.Value as string);
            var zxcvbn    = Zxcvbn.Zxcvbn.MatchPassword(clearPass);

            if (!(zxcvbn.Score > 2))
            {
                cell.ErrorText = "Password too easy";
                isPassValid    = false;
            }
            else
            {
                if (!(clearPass.Length <= 20))
                {
                    cell.ErrorText = "Password can't contain over 20 symbols";
                    isPassValid    = false;
                }
                else
                {
                    cell.ErrorText = "";
                    isPassValid    = true;
                    var rawpass = MetaBackEnd.getCorrectPass(cell.Value as string);
                    var bsalt   = MetaBackEnd.GenerateSalt();
                    var bpass   = MetaBackEnd.CalcHash(rawpass, bsalt);
                    cell.Value = bpass;
                    cell.Tag   = bsalt;
                }
            }
            SyncBtnSignUpState();
        }