private void cmd_Submit_Click(object sender, RoutedEventArgs e) { string name = txt_Name.Text; string password = txt_password.Text; string query = $"SELECT password FROM users where name ='{name}';"; DbConnectorParam loginCheck = new DbConnectorParam(query); query = $"SELECT salt FROM users where name ='{name}';"; DbConnectorParam loginSalt = new DbConnectorParam(query); string salt = loginSalt.Result; if (new Password_Verfy(txt_password.Text, loginSalt.Result, loginCheck.Result).result) { if (password == loginCheck.Result) { Console.WriteLine("Connexion reussi"); } else { Console.WriteLine("Connexion fail"); } Application.Current.Shutdown(); } else { Application.Current.Shutdown(0); } }
private void cmd_login_Click(object sender, EventArgs e) { string name = txt_name.Text; string password = txt_password.Text; string query = $"SELECT password FROM users where name ='{name}';"; DbConnectorParam loginCheck = new DbConnectorParam(query); query = $"SELECT salt FROM users where name ='{name}';"; DbConnectorParam loginSalt = new DbConnectorParam(query); if (loginCheck.Result != null) { if (new Password_Verfy(txt_password.Text, loginSalt.Result, loginCheck.Result).result) { Console.WriteLine("Connexion reussi"); DialogResult = DialogResult.OK; username = txt_name.Text; Close(); } else { MessageBox.Show("Connexion fail your username or password is incorrect"); txt_name.Text = ""; txt_password.Text = ""; } } else { MessageBox.Show("Not data found"); } }
private void cmd_submit_Click(object sender, EventArgs e) { if (txt_pwd.Text == txt_confirmPwd.Text) { hashPassword hashPassword = new hashPassword(txt_pwd.Text); string query = $"SELECT password FROM users where name ='{txt_name.Text}';"; DbConnectorParam userCheck = new DbConnectorParam(query); if (userCheck.Result == "") { string squery = $"INSERT INTO users(name,password,salt)VALUE('{txt_name.Text}','{hashPassword.Pwd_hashed}','{hashPassword.Pwd_Salt}');"; DbConnectorParam registring = new DbConnectorParam(squery); DbConnectorParam registryCheck = new DbConnectorParam(query); if (registryCheck.Result == hashPassword.Pwd_hashed) { DialogResult = DialogResult.OK; Close(); } else { MessageBox.Show("Register fail"); } } else { MessageBox.Show("Le nom d'utilisateur fourni est déjà utilisé\n Veuillez inserer un autre nom"); } } else { MessageBox.Show("password not match"); } }