كتاب الْمَسَاجِدِ وَمَوَاضِعِ الصَّلاَةِ
5  
The Book of Mosques and Places of Prayer
(17)
Chapter: Prohibiting one who has eaten garlic, onions, or leeks, and other things that have an offensive odor from coming to the masjid, until that smell has gone away, and such a person should be expelled from the masjid
(17)
باب نَهْىِ مَنْ أَكَلَ ثُومًا أَوْ بَصَلاً أَوْ كُرَّاثًا أَوْ نَحْوَهَا عَنْ حُضُورِ الْمَسْجِدِ ‏‏
Sahih Muslim 564 c

Jabir b. 'Abdullah reported the Messenger of Allah (ﷺ) mying:

He who eats of this (offensive) plant, i. e garlic, and sometirres he said: He who eats onion and garlic and leek, should not approach our mosque for the angels are harmed by the same things as the children of Adam.
وَحَدَّثَنِي مُحَمَّدُ بْنُ حَاتِمٍ، حَدَّثَنَا يَحْيَى بْنُ سَعِيدٍ، عَنِ ابْنِ جُرَيْجٍ، قَالَ أَخْبَرَنِي عَطَاءٌ، عَنْ جَابِرِ بْنِ عَبْدِ اللَّهِ، عَنِ النَّبِيِّ صلى الله عليه وسلم قَالَ ‏ "‏ مَنْ أَكَلَ مِنْ هَذِهِ الْبَقْلَةِ الثُّومِ - وَقَالَ مَرَّةً مَنْ أَكَلَ الْبَصَلَ وَالثُّومَ وَالْكُرَّاثَ - فَلاَ يَقْرَبَنَّ مَسْجِدَنَا فَإِنَّ الْمَلاَئِكَةَ تَتَأَذَّى مِمَّا يَتَأَذَّى مِنْهُ بَنُو آدَمَ ‏"‏ ‏.‏
Reference : Sahih Muslim 564c
In-book reference : Book 5, Hadith 92
USC-MSA web (English) reference : Book 4, Hadith 1147
  (deprecated numbering scheme)