Esempio n. 1
0
        public static bool updatePassword(string Username, string Password)
        {
            try
            {
                var hash = PasswordEncryption.GeneratePasswordHash(Password);

                using (MySqlConnection connection = new MySqlConnection(conString))
                {
                    connection.Open();

                    MySqlCommand comm = connection.CreateCommand();

                    comm.CommandText = "UPDATE users SET Pwd=@PWD WHERE Username = @UN";

                    comm.Parameters.AddWithValue("@UN", Username);
                    comm.Parameters.AddWithValue("@PWD", hash);

                    comm.ExecuteNonQuery();
                    return(true);
                }
            }
            catch (Exception e)
            {
                log.Error("Exception thrown from method " + GetCurrentMethod(), e);
                return(false);
            }
        }