Umar asked the Prophet ﷺ, "Can one of us sleep while in a state of major ritual impurity?"He replied, "Yes, if he performs ablution."
حدثنا محمد بن المثنى حدثنا يحيى بن سعيد عن عبيد الله بن عمر عن نافع
عن عمر أنه سأل النبي ﷺ أينام أحدنا وهو جنب قال نعم إذا توضأ
Agreed upon [by Bukhari and Muslim]. Muslim also recorded it in the Book of Menstruation, chapter on the permissibility of a person in a state of major impurity sleeping etc., hadith no. 306, from the narration of Yahya Qattan. Bukhari recorded it in the Book of ghusl, chapter on a person in a state of major impurity performing wudu and then sleeping, hadith no. 289, from the narration of Nafi with the same wording.On this subject there are also narrations from Ammar [Abu Dawud, hadith no. 4180, and Tirmidhi], Ayesha [Bukhari, hadith no. 288, and Muslim, hadith no. 305], Jabir [Ibn Majah, hadith no. 592], Abu Saeed Khudri [Ibn Majah, hadith no. 586], and Umm Salama [al-Saghir by Tabarani and Majma al-Zawaid, 1/274].