The Prophet ﷺ said, "Whoever sees me in a dream has truly seen me, for Satan cannot take my form. The dream of a believer is one of forty-six parts of prophethood."
قال النبي ﷺ: من رآني في المنام فقد رآني، فإن الشيطان لا يتخيل بي، ورؤيا المؤمن جزء من ستة وأربعين جزءا من النبوة.
Bukhari narrated it in the Book of Dream Interpretation (6994), and this is his wording, and Muslim narrated it in the Book of Dreams (2264), both through two routes from Thabit Bunani from Anas bin Malik, and he related it. Muslim's account is abridged, limited to the last portion of the text.Restricting the negation to Satan, without mentioning the jinn, points to the fact that satanic powers are incapable of impersonation, so the jinn are even less capable. All of this serves to protect the pure sharia, so that no one could claim to be the Prophet ﷺ and abrogate any of its rulings. So whoever claims in a dream to abrogate something from the rulings of the sharia, or to bring new legislation, is not the Prophet ﷺ. Rather, he merely resembles the Prophet ﷺ, and he is in fact the accursed Satan.