One day, while the Messenger of Allah ﷺ was delivering a sermon, he noticed a glob of phlegm on the qiblah wall of the mosque. He became angry with the people and then scraped it off.The narrator said, I believe he said that the Prophet then called for some saffron and smeared it over the spot, saying, "When one of you prays, Allah is before his face, so let him not spit in front of him."
حدثنا سليمان بن داود حدثنا حماد حدثنا أيوب عن نافع
بينما رسول الله ﷺ يخطب يوما إذ رأى نخامة في قبلة المسجد فتغيظ على الناس ثم حكها قال وأحسبه قال فدعا بزعفران فلطخه به وقال إن الله قبل وجه أحدكم إذا صلى فلا يبزق بين يديه
Bukhari narrated it in "Actions During Prayer," in the chapter on what is permissible regarding spitting and blowing during prayer, hadith no. 1213, from the hadith of Hammad with this wording. Muslim narrated it in "Masjids," in the chapter on the prohibition of spitting in the masjid, hadith no. 547, from the hadith of Ayub Sakhtiyani with this wording.