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.
quran:39:8

And when adversity touches man, he calls upon his Lord, turning to Him ˹alone˺; then when He bestows on him a favor from Himself, he forgets Him whom he called upon before, and he attributes to Allah equals to mislead ˹people˺ from His way. Say, "Enjoy your disbelief for a little; indeed, you are of the companions of the Fire."  

And when distress befalls a person, that is, the disbeliever, he supplicates his Lord, he implores, turning, returning, to Him penitently. Then, when He bestows on him a grace from Himself, he forgets, he neglects, Him Whom he had supplicated, implored, before, namely, God (in other words mā functions as min, ‘whom’) and sets up equals, associates, with God, that he may lead ˹others˺ astray (read li-yadilla or li-yudilla) from His way — ˹from˺ the religion of Islam. Say: ‘Revel in your ingratitude for a while — for the remainder of your term ˹of life˺. You shall indeed be among the inhabitants of the Fire’.
القرآن:٣٩:٨

وَإِذَا مَسَّ الْإِنْسَانَ ضُرٌّ دَعَا رَبَّهُ مُنِيبًا إِلَيْهِ ثُمَّ إِذَا خَوَّلَهُ نِعْمَةً مِنْهُ نَسِيَ مَا كَانَ يَدْعُو إِلَيْهِ مِنْ قَبْلُ وَجَعَلَ لِلَّهِ أَنْدَادًا لِيُضِلَّ عَنْ سَبِيلِهِ ۚ قُلْ تَمَتَّعْ بِكُفْرِكَ قَلِيلًا ۖ إِنَّكَ مِنْ أَصْحَابِ النَّارِ  

{وإذا مسَّ الإنسان} أي الكافر {ضرٌ دعا ربه} تضرَّع {منيبا} راجعا {إليه ثم إذا خوّله نعمة} أعطاه إنعاما {منه نسيَ} ترك {ما كان يدعو} يتضرّع {إليه من قبل} وهو الله، فما في موضع من {وجعل الله أندادا} شركاء {ليضل} بفتح الياء وضمها {عن سبيله} دين الإسلام {قل تمتع بكفرك قليلا} بقية أجلك {إنك من أصحاب النار}.