Imam al-Sadiq (as) said: “When you arrive at the door of the mosque, know that you have come to the door of a great King. No one may walk into His Courtyard save the purified, and no one is admitted to His Company [mu’anasah] but the truthful. So, attach reverence to your coming to the ground of serving the King, as you would be exposed to a great danger if you were negligent. Know that He is capable of doing what He likes of justice and grace with you and by you. So, if He was kind to you with His mercy and favour, He would accept from you little worship and give you much reward for it. But if He demanded from you a share of truth and sincerity, to be just with you, He would block you and reject your worship, even if it is much. He is the doer of what He wants. Confess to His Presence your inability, shortcoming, humility and poverty, as you have come to Him to worship and to get His Intimacy [mu’anasah]. Expose your secrets to Him, knowing that nothing, covert and overt, of the entire universe, is hidden from Him. Be, before Him, as the poorest of His servants. Empty your heart of all occupants that keep you away from your Lord, as He does not accept except the purest and the sincerest. Find out in which register your name is recorded. If you tasted the sweetness of supplication and the delight of addressing Him, and drank from the cup of His mercy and generosity out of His good reception of you and response to you, then you would become suitable for His service. So, enter, as you will have permission and protection. Otherwise, stop, like the one whose rope has snapped, and his hope has come short, and time has got the better of him. So, if Allah found in your heart true recourse to Him, He would look at you with the eye of kindness, mercy and leniency, and cause you to be successful in attaining to what He likes and is pleased with, since He is generous and loves generosity for His servants who distressfully resort to Him and burn out at His door for the want of His pleasure. Allah, the Most High, says: ‘Or, Who answers the distressed one, when he calls upon Him, and removes the evil … ?'”

Source: Misbahush Shar’iah, ch. on “Entering the Mosque”. The Qur’anic verse at the end of the hadith is verse 62 from Surah an-Naml. (See Image below)