Thanks to the 2009 federal legislation "Protecting Tenants at Foreclosure Act of 2009", most tenants with leases will keep their leases, and month-to-month tenants will have at least 90 days to relocate. Tenants with leases have no legal recourse against their former landlords, because they are in the same position vis a vis the new owner as they were with the old: The lease survives and ends as it would had there been no foreclosure. Similarly, month-to-month tenants always know that they can be terminated with proper notice, and 90 days is longer than any state's termination period.
However, a lease-holding tenant whose rental has been bought by a buyer who want to move in to the property ends up less fortunate than before the new law -- he may lose his lease with 90 days' notice, a result that probably would not have happened had the owner simply sold the property to a buyer who intended to occupy the property. (Normally, the new owner has to wait until the lease ends, absent a lease clause providing for termination upon sale, though such clauses may not be legal in all situations. As I'm not an attorney it would be advisable to contact one in this instance.)
Hope that this helps.
(Information deemed reliable, but not guaranteed.)