Family Law Questions? Ask a Family Lawyer Online.
You can stay until the house is actually forclosed and sold in which case you will receive notice that you can stay by permission of the new owner or you must leave. Legally you must continue to pay rent even when the house is in forclosure or the owner can evict you.
I doubt the bank will allow you to assume the mortgage with bad credit as you normally would need to qualify for a mortgage and with bad credit that can be very hard. If the bank allows you to continue to live in the property which is completely up to the bank then you would continue to be a tenant.
An exception was carved out for the buyer who intends to live on the property -- this buyer may terminate a lease with 90 days' notice. Importantly, the law provides that any state legislation that is more generous to tenants will not be preempted by the federal law. These protections apply to Section 8 tenants, too.