Sayyiduna Jabir bin Abdullah (may Allah be pleased with them both) says that the Prophet (peace and blessings be upon him) forbade eating onions and leeks, but when in need we would eat them. The Prophet (peace and blessings be upon him) said: "Whoever eats of this foul plant, let him not come near our mosque, for the angels too are harmed by what harms human beings."
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الصلاة / 5054