There's this thing call sedition. The Sedition Act is the law in question. It's illegal to talk bad about the President, The Flag, The Governeent and the Country. The reason for the law is to protect America during war time.
Sedition Act of 1918 - Wikipedia, the free encyclopedia
Congress repealed the Sedition Act on December 13, 1920