Haha. Bits and pieces. I came to this as a tenant activist from long ago who, because she mercifully lives in a state with nonjudicial foreclosure, was able to quickly digest most of the rules on tenants and foreclosure. I don't know the rules for other states--either landlord-tenant or foreclosure. I did run across this nifty little chart from the National Low Income Housing Coalition. It provides very basic information on foreclosures, where they have been able to glean that information. And they've now come out with a new report that includes more information for tenants facing foreclosure, including timelines for many states. NLIHC published an updated report here, and page 10 of that report has a map of states with more tenant protections than the federal Protecting Tenants at Foreclosure Act. (And yes, the states with no additional protections for tenants are almost all states that voted for Mitt Romney in the 2012 election.) Still, you should contact a local tenant organization or legal aid group, as you'll need more help than this provides to negotiate the process. If you live in a small town, try searching for a tenants' assistance line in a major city in your state. The rules may not be the same, as some large cities provide more protections for tenants that the state government allows, but the tenants' organization will at least know what the state law provides.
And if you live in a state that required no notice, or very little, before the passage of the federal legislation, you should read below on the possible bad behaviors of lenders and their agents, as they will use all sorts of nefarious tricks to part you from your home without having to give you the required notice.
I will also remind you to get any agreement with the lender with respect to "cash for keys," additional time to move, return of your security deposit etc. IN WRITING. Any cash settlement should be paid by cashier's check or money order.
Oregon tenants have new rights in foreclosure. Tenants there now have the right to 120-days notice that their homes are under threat of foreclosure. And tenants may withhold rent prior to the foreclosure sale to recover their security deposits. More information is here.