Many sites send mail to a specified email address containing a randomly generated verification code, and only accept user registration as soon as the user confirms that they were able to read this mail and receive a confirmation code. Typically, the mail contains a URL that the user can simply click to confirm.
If you do this, all you have to do is send a confirmation email to inform the user that they have already registered and explain the reset password procedure.
No matter what the web development framework may have, there is a package that processes confirmation letters.
Please note that you need to think about when the user had an email address and used it to register on your site, then they disappeared without changing the address and stopped using the address, and the other user now has an address and wants to register. There is no simple answer.
ADDED . You add that you do not want to receive a confirmation email so that registration takes place immediately. This requirement is contrary to unique email addresses because you do not know that the email address provided by the user is legal until it is verified, and it makes no sense to use the uniqueness of the user-selected string, which is simply formatted as an email address (if you want a unique username, it does not need to be formatted as an email address).
If you want to keep instant registration, you will only need to treat email addresses as an untrusted text field until confirmation. This means that every action that requires your site to send mail must be bombed if the user has not verified his email address. The confirmation process remains almost the same, but now, if the address is a duplicate, the user should be given the opportunity to combine the two accounts (which is difficult), or said that he should close one of the two accounts or change the email address associated with one of two accounts.
source share