Riyad as-Salihin 424: On Hope and Good Expectation
Abu Hurairah relates that the Holy Prophet said: A servant of Allah committed a sin and then supplicated: Allah, forgive me my sin. On which Allah, the Blessed and the High, said: My servant committed a sin and then realised that he has a Lord Who forgives sin and also calls to account for it. The servant reverted to it and sinned again and supplicated: Lord, forgive me my sin. The Blessed and the High said: My servant committed a sin and then realised that he has a Lord Who forgives sin and also calls to account for it. The servant again reverted to it and sinned and supplicated: Lord, forgive me my sin. The Blessed and the High said: My servant committed a sin and then realised that he has a Lord Who forgives sin and also calls to account for it. I have forgiven My servant; so let him do what he wishes (meaning, so long as he goes on repenting) (Bokhari and Muslim).
وقوله تعالى: “فليفعل ما شاء” أي: ما دام يفعل هكذا، يذنب ويتوب اغفر له، فإن التوبة تهدم ما قبلها.