예제 #1
0
파일: FormAuth.cs 프로젝트: Wykh/ARM
 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");
         }
     }
 }
예제 #2
0
        private void btnSignUp_Click(object sender, EventArgs e)
        {
            using (var ctx = new UsersContext())
            {
                var login      = MetaBackEnd.getCorrectLogin(tbLogin.Text);
                var rawpass    = MetaBackEnd.getCorrectLogin(tbPass.Text);
                var birthDate  = dtpBirthDate.Value;
                var signUpDate = DateTime.Now;
                var idSpecial  = ctx.specials.SingleOrDefault(spec => tbSpecial.Text == spec.special_code).id;
                var bsalt      = MetaBackEnd.GenerateSalt();
                var bpass      = MetaBackEnd.CalcHash(rawpass, bsalt);

                var newUser = new awp_users
                {
                    gender      = genderName,
                    login_      = login,
                    password    = bpass,
                    birth_date  = birthDate,
                    signup_date = signUpDate,
                    salt        = bsalt,
                    id_special  = idSpecial
                };
                ctx.awp_users.Add(newUser);
                ctx.SaveChanges();
            }
        }
예제 #3
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();
        }
예제 #4
0
파일: FormUsers.cs 프로젝트: Wykh/ARM
 private void CheckLogin(DataGridViewCell cell)
 {
     //Here is login cheking            i
     if (!loginRegex.IsMatch(MetaBackEnd.getCorrectLogin(cell.Value as string)))
     {
         cell.ErrorText = "Login должен состоять из 6 to 50 letters of 'А-Яа-я0-9A-Za-z' and space";
         isLoginValid   = false;
     }
     else
     {
         using (var ctx = new UsersContext())
         {
             var user = ctx.awp_users.SingleOrDefault(us => us.login_.ToLower() == ((string)cell.Value).ToLower());
             if (user != default)
             {
                 cell.ErrorText = "Login is already used";
                 isLoginValid   = false;
             }
             else
             {
                 cell.ErrorText = "";
                 isLoginValid   = true;
             }
         }
     }
     SyncBtnSignUpState();
 }
예제 #5
0
파일: FormUsers.cs 프로젝트: Wykh/ARM
        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();
        }
예제 #6
0
 private void tbLogin_TextChanged(object sender, EventArgs e)
 {
     if (!loginRegex.IsMatch(MetaBackEnd.getCorrectLogin(tbLogin.Text)))
     {
         errorSign.SetError(tbLogin, "Login должен состоять из 6 to 50 letters of 'А-Яа-я0-9A-Za-z' and space");
         isLoginValid = false;
         return;
     }
     using (var ctx = new UsersContext())
     {
         var user = ctx.awp_users.SingleOrDefault(us => us.login_.ToLower() == tbLogin.Text.ToLower());
         if (user != default)
         {
             errorSign.SetError(tbLogin, "Login is already used");
             isLoginValid = false;
         }
         else
         {
             errorSign.SetError(tbLogin, "");
             isLoginValid = true;
         }
     }
 }
예제 #7
0
파일: FormAuth.cs 프로젝트: Wykh/ARM
 public FormAuth()
 {
     InitializeComponent();
     MetaBackEnd.WarmupDbConnectionToUsers();
 }
예제 #8
0
 public FormReg()
 {
     InitializeComponent();
     MetaBackEnd.WarmupDbConnectionToUsers();
     btnSignUp.Enabled = false;
 }