Narrated Abu Huraira: The Prophet ﷺ said, "The one who commits an illegal sexual intercourse is not a believer at the time of committing illegal sexual intercourse and a thief is not a believer at the time of committing theft and a drinker of alcoholic drink is not a believer at the time of drinking. Yet, (the gate of) repentance is open thereafter".
The Prophet Muhammad also taught us that those who commit illegal sexual intercourse, theft or drink alcohol are not believers at the time of their actions. However, this does not mean that they cannot be forgiven; rather it means that they must sincerely repent in order for Allah to forgive them. We should strive to stay away from these sins so as not to put ourselves in a position where repentance may become necessary.