Madan bin Abu Talha reported,

Umar bin Khattab delivered a Friday sermon in which he said, "People, you eat two plants that I consider nothing but foul, this onion and garlic. I saw the Messenger of Allah ﷺ, whenever he detected their smell on a man in the mosque, order him to be taken out to al-Baqi. So whoever eats them, let him kill their odor by cooking."

Azami 3147

Sahih

عن معدان بن أبي طلحة

قال ان عمر بن الخطاب، خطب يوم الجمعة فقال: ايها الناس تأكلون شجرتين لا اراهما الا خبيثتين. هذا البصل والثوم. لقد رأيت رسول الله ﷺ اذا وجد ريحهما من الرجل في المسجد، امر به فأخرج الي البقيع، فمن اكلهما فليمتهما طبخا.

الأعظمي 3147صحيح
Contents
Reference
Commentary
Ayat
Collection
Jami al-Kamil
Book
Mosques
Section
Prohibition of coming to the mosques after eating garlic, onions, and leeks
Numbering
Jami al-Kamil 3147 (2nd edition)
Azami 3147