al-Salamu `Aleykum,
We often come across this but this time I feel posting it...
محمد بن يعقوب، عن علي بن إبراهيم، عن محمد بن عيسى، عن يونس عن معاوية بن وهب قال: سألت أبا عبدالله (عليه السلام) عن النوم في المسجد الحرام ومسجد الرسول (صلى الله عليه وآله)؟ قال: نعم
[`Ali bin Ibrahim, from Muhammad bin `Isa, from Yunus, from Mu`awiyah bin Wahb that he said: I asked abu `Abdillah (as) about sleeping in the Masjid al-Haram and the Masjid al-Nabawi, he said: It's allowed.]
source: al-Kafi 3/369 #10.
وعنه، عن أبيه، عن حماد، عن حريز، عن زرارة بن أعين قال: قلت لأبي جعفر (عليه السلام): ما تقول في النوم في المساجد؟ فقال: لا بأس به، إلا في المسجدين: مسجد النبي (صلى الله عليه وآله) والمسجد الحرام
[`Ali bin Ibrahim, from his father, from Hammad, from Hurayz, from Zurarah bin A`yyan that he said: I told abu Ja`far (as): What is your verdict on sleeping in the Masaajid? He said: No harm in this, except for two: Masjid al-Nabi and Masjid al-Haram.]
source: al-Kafi 3/370 #11.
عن عبدالله بن الحسن، عن جده علي بن جعفر، عن أخيه، قال: سألته عن النوم في المسجد الحرام؟ قال: لابأس، وسألته عن النوم في مسجد الرسول؟ قال: لا يصلح
[From `Abdullah bin al-Hasan, from his grandfather `Ali bin Ja`far, from his brother, He said: I asked him about sleeping in the Masjid al-Haram? He repied: No harm in this. Then I asked him about sleeping in Masjid al-Rasul? He said: Not allowed.]
source: Qurb al-Isnad pg.69 #6382.
al-Baqir says: You cannot sleep in al-Masjid al-Nabawi nor al-Masjid al-Haram but the rest are ok.
al-Sadiq his son contradicts him and says: There is no issue in sleeping in any Masjid.
al-Kadhim his grandson contradicts both and says: No issue in sleeping in Masjid al-Haram but not in al-Nabawi.
The joys of infallibility. This is what I call "Lutf", Allah left us without an infallible and we only have conflicting Hadith.