User sign-up with email verification

試著忘記壹切 提交于 2019-12-03 01:29:51

The algorithm is something like this:

  1. Save the user's info, marking it with a pending status.
  2. Generate a token that contains some info related to the user's account.
  3. Generate the email, which must include the URL to activate the account and the URL will have the token in it.
  4. The URL must point to some servlet or service in your app that will validate the token, check if the user related to the token is inactive, present a completion form (let the user set a password, present a captcha, etc) and on form submission you activate the account with the password they set.
  5. You should periodically scan the inactivate accounts and delete the ones that are several days old and have not been activated.

To generate the token, you can encrypt some data such as user ID, email, etc and encode it in Base 64 (the URL-safe variant) - remember to salt it when you encrypt. When you receive the token, you decode and decrypt it, and it must point to an inactivate user account.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!