Caution: Translations of Quran and Ḥadīth may lead to possible misapplications and misinterpretations. This site is intended for students of sacred knowledge that are proficient in comprehending classical Arabic and have a strong foundation in Islamic sciences. Also note that religious injunctions rely on several aspects beyond what one may glean through reading individual aḥādīth.
ahmad:15795ʿAttāb b. Ziyād > ʿAbdullāh > Ibn Lahīʿah > Mūsá b. Jubayr a freed slave of Banī Salimah > ʿAbdullāh b. Kaʿb b. Mālik from his father

[Machine] People used to fast during Ramadan, and when a man woke up after sleeping, it was forbidden for him to have food, drink, or have relations with women, until he broke his fast the next morning. Omar ibn Al-Khattab returned from the Prophet ﷺ one night, having spent the night with him, and found his wife sleeping. He wanted to approach her but she said, "I am sleeping." He said, "You did not sleep," and then had relations with her. Ka'b ibn Malik did the same thing. The next day, Omar went to the Prophet ﷺ and informed him of what happened. Allah then revealed the verse, "Allah knew that you used to deceive yourselves, so He accepted your repentance and forgave you" (Surah Al-Baqarah, 2:187).  

أحمد:١٥٧٩٥حَدَّثَنَا عَتَّابُ بْنُ زِيَادٍ قَالَ أَخْبَرَنَا عَبْدُ اللهِ قَالَ أَخْبَرَنَا ابْنُ لَهِيعَةَ قَالَ حَدَّثَنِي مُوسَى بْنُ جُبَيْرٍ مَوْلَى بَنِي سَلِمَةَ أَنَّهُ سَمِعَ عَبْدَ اللهِ بْنَ كَعْبِ بْنِ مَالِكٍ يُحَدِّثُ عَنْ أَبِيهِ قَالَ

كَانَ النَّاسُ فِي رَمَضَانَ إِذَا صَامَ الرَّجُلُ فَأَمْسَى فَنَامَ حَرُمَ عَلَيْهِ الطَّعَامُ وَالشَّرَابُ وَالنِّسَاءُ حَتَّى يُفْطِرَ مِنَ الْغَدِ فَرَجَعَ عُمَرُ بْنُ الْخَطَّابِ مِنْ عِنْدِ النَّبِيِّ ﷺ ذَاتَ لَيْلَةٍ وَقَدْ سَهِرَ عِنْدَهُ فَوَجَدَ امْرَأَتَهُ قَدْ نَامَتْ فَأَرَادَهَا فَقَالَتْ إِنِّي قَدْ نِمْتُ قَالَ مَا نِمْتِ ثُمَّ وَقَعَ بِهَا وَصَنَعَ كَعْبُ بْنُ مَالِكٍ مِثْلَ ذَلِكَ فَغَدَا عُمَرُ إِلَى النَّبِيِّ ﷺ فَأَخْبَرَهُ فَأَنْزَلَ اللهُ تَعَالَى {عَلِمَ اللهُ أَنَّكُمْ كُنْتُمْ تَخْتَانُونَ أَنْفُسَكُمْ فَتَابَ عَلَيْكُمْ وَعَفَا عَنْكُمْ} [البقرة 187]