/// <summary>
        /// Check if the username and the password of the user is correct
        /// </summary>
        /// <param name="login"></param>
        /// <returns>True if OK</returns>
        /// <returns>Exception if not OK</returns>
        public bool LoginDb(Login login)
        {
            CheckData      loginCheck = new CheckData();
            DbConnection   connection = new DbConnection();
            CryptoPassword c          = new CryptoPassword();

            //Check if the fields aren't empty
            loginCheck.CheckLoginField(login.userEmail, login.password);
            //Check if the userEmail exist in the database
            if (!connection.CheckEmail(userEmail))
            {
                return(false);
            }
            //Get the password form the database from the validated userEmail
            var hashedPassword = connection.GetUserPassword(userEmail);

            //Return true or false if the input password match or not the database password
            return(c.Verify(password, hashedPassword));
        }
        /// <summary>
        /// Register new users in the database, also check if the username is already used.
        /// </summary>
        /// <param name="reg">Contains userEmail, username and a password</param>
        /// <returns>True: Everything OK</returns>
        ///
        public bool RegisterInDb(Register reg)
        {
            DbConnection   connection     = new DbConnection();
            CryptoPassword c              = new CryptoPassword();
            string         hashedPassword = c.Hash(password);
            CheckData      registerCheck  = new CheckData();

            try
            {
                if (!registerCheck.CheckRegisterField(reg.userEmail, reg.password, reg.passwordCheck))
                {
                    return(false);
                }

                if (!registerCheck.VerifRegister(reg.userEmail, reg.password))
                {
                    return(false);
                }
                if (connection.CheckIfUserEmailExistInDb(userEmail))
                {
                    return(false);
                }

                if (!connection.InsertDataInDb(username, userEmail, hashedPassword))
                {
                    return(false);
                }
            }
            catch (InvalidEmailAddressException e)
            {
                MessageBox.Show(e.Message);
                return(false);
            }
            catch (EmptyFieldException e)
            {
                MessageBox.Show(e.Message);
                return(false);
            }
            catch (EmailTooShortException e)
            {
                MessageBox.Show(e.Message);
                return(false);
            }
            catch (PasswordTooShortException e)
            {
                MessageBox.Show(e.Message);
                return(false);
            }
            catch (UserEmailAlreadyExistException e)
            {
                MessageBox.Show(e.Message);
                return(false);
            }
            catch (MySqlException e)
            {
                MessageBox.Show("Un erreur est survenu lors de la connection avec la base de donnée");
                return(false);
            }

            return(true);
        }