Jabir bin Abdullah reported,

The Messenger of Allah ﷺ forbade eating onions and leeks, but necessity overcame us and we ate some of them. He said, "Whoever eats from this foul-smelling plant should not come near our mosque, for the angels are offended by what offends humans."

Muslim 1252

Sahih

حدثنا أبو بكر بن أبي شيبة حدثنا كثير بن هشام عن هشام الدستوائي عن أبي الزبير

عن جابر قال

نهى رسول الله ﷺ عن أكل البصل والكراث فغلبتنا الحاجة فأكلنا منها فقال من أكل من هذه الشجرة المنتنة فلا يقربن مسجدنا فإن الملائكة تأذى مما يتأذى منه الإنس

مسلم 1252صحيح
Contents
Reference
Commentary
Ayat
Collection
Sahih Muslim
Book
Mosques and places of prayer
Chapter
Prohibition on those who have eaten garlic, onions, leeks, or similar from attending the masjid
Numbering
Darussalam 1252
Muslim 1252