Congressional law

Which Congressional law prohibited labour unions from contributing money to candidates in federal elections and how did Political Action Committees (PACs) allow unions to circumvent this prohibition?