Joseph Fielding McConkie and Craig J. Ostler discuss the incident of Joseph detecting Satan as an angel of light.
Joseph Fielding McConkie and Craig J. Ostler, Revelations of the Restoration: A Commentary on the Doctrine and Covenants and Other Modern Revelations (Salt Lake City, UT: Deseret Book, 2000), 1035, 1040
Michael ... detecting the devil when he appeared as an angel of light. No account has been preserved of the occasion when Michael, or Adam, appeared to aid the Prophet in detecting the devil when he appeared as an angel of light. Lehi, in his great discourse on the Atonement, refers to the fact that the devil attempted to deceive Adam and Eve in the same manner (2 Nephi 9:9). This may suggest that Adam by virtue of his own experience in such things came to aid the Prophet as a mentor on this occasion. See introduction to commentary on Doctrine and Covenants 129.
. . .
The Prophet recorded that Michael (Adam) appeared to him "on the banks of the Susquehanna, detecting the devil when he appeared as an angel of light!" (D&C 128:20). It would appear that this experience took place while Joseph was translating the Book of Mormon in Harmony, Pennsylvania. It was here that John the Baptist restored to the Prophet and Oliver Cowdery the "keys of the ministering of angels" (Joseph Smith-History 1:69; D&C 13:1). Thus, the right to receive the ministration of angels and the ability to discern true messengers of God from counterfeits came before the Church was organized.