Sayyidah Aishah (may Allah be pleased with her) said: When the Prophet (peace and blessings be upon him) came, the doors of the Companions' houses opened onto the mosque. He (peace and blessings be upon him) said: "Turn the doors of these houses away from the mosque." Then he (peace and blessings be upon him) went into the house, and the people did not change the doors of their houses, hoping that he (peace and blessings be upon him) might grant them a concession. Then he (peace and blessings be upon him) came out to them and said: "Turn the doors of these houses away from the mosque, for I do not make the mosque lawful for a menstruating woman or for one in a state of major impurity (junub)."
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الصلاة / 4323