Ejemplo n.º 1
0
        protected void button1_Click(object sender, EventArgs e)
        {
            string       email   = textBoxMail.Text.ToLower(); //récupère le mail passé
            string       pwd     = textBoxPassword.Text;       //récupère le mot de passe passé
            MySqlCommand command = conn.CreateCommand();

            command.Parameters.AddWithValue("@email", email);
            command.CommandText = "SELECT email, password, idClient FROM client WHERE email = @email;";
            try
            {
                conn.Open();
                MySqlDataReader reader = command.ExecuteReader();
                int             i      = 0;
                while (reader.Read()) //Si on trouve dans la base de donnée un mail correspondant
                {
                    i++;
                    string valeur = reader.GetString(0);
                    if (BCrypt.Net.BCrypt.Verify(pwd, reader.GetString(1))) //Si le hash du mot de passe enregistré est le même que le mot de passe enregistré
                    {
                        string   client   = reader.GetString(2);
                        Boutique Boutique = new Boutique(client);
                        Boutique.Show(); //Affiche le magasin coorespondant
                        this.Hide();
                    }
                    else // Si les mots de passes ne correspondent pas
                    {
                        MessageBox.Show("Adresse mail ou mot de passe incorrect");
                    }
                }
                if (i == 0) //Si on a pas trouvé de mail correspondant
                {
                    MessageBox.Show("Adresse mail ou mot de passe incorrect");
                }
                conn.Close();
            }
            catch (MySqlException ex)
            {
                Console.WriteLine(ex);
            }
        }