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:22:11

And of the people is he who worships Allah on an edge. If he is touched by good, he is reassured by it; but if he is struck by trial, he turns on his face ˹to the other direction˺. He has lost ˹this˺ world and the Hereafter. That is what is the manifest loss.  

And among mankind there are those who worship God on a knife-edge: that is, with uncertainty in his worship — such ˹a person˺ has been likened the ˹knife-˺ edge of a mountain in his precariousness — if good ˹fortune˺ befalls him, ˹so that he enjoys˺ health and security with respect to his own self and his property, he is reassured by it; but if an ordeal befalls him, a trial or ill-health with regard to himself or his property, he makes a turnabout, that is, he reverts to disbelief, losing both this world, when what he had hoped for in it has eluded him, and the Hereafter, by ˹his˺ disbelief. That is the manifest loss.
القرآن:٢٢:١١

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

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