He Prayed In a State of Janaabah Because He Forgot, And Then He Remembered After a While. What Should Be Done Thereafter?

Question

Muslims unanimously agree that it is forbidden for one who is in a state of impurity to pray, and that such a prayer is not valid, regardless of whether he knew that he was in a state of impurity, or he was unaware of that, or he forgot. But if he prayed out of ignorance or he forgot, there is no sin on him. If someone forgets to purify himself from impurity and prays in that state, then he must repeat the prayer after purifying himself, and there is no difference of Scholarly opinion concerning that.