the idea is:
- generate a CAPTCHA (the simplest thing is to use a random number)
- store the CAPTCHA in the database table, and be sure to have an expiration time
- assemble the CAPTCHA and copy according to the predetermined format
- call the API for sending SMS messages to send SMS messages
- users receive SMS messages and go to the corresponding place for verification according to the verification code
- the backend API verifies the sent verification code and the valid verification code in the database, and passes it, otherwise it will not pass.
generally save session
better ones are stored in redis, with good validity control
the verification code you generate should be saved, and then the user receives it and enters it. You accept the verification code entered by the user and compare it with the verification code you saved before, and pass it. When you report an error
when storing a verification code, you can consider adding an expiration time
this wheel is good. You can try it. If https://github.com/overtrue/e.
is in use, if I don't say 233333
, save it in both the database and cache, so that there are records on both sides. It is convenient to check
1, generate a 6-digit SMS verification code, generate a rediskey, to save the SMS verification code, and give a valid time, and then tell the client the rediskey.
2, call the SMS service provider api to send SMS messages,
3. When submitted by the client, post carries the SMS verification code entered by rediskey,. According to the rediskey, the backend calls up the SMS verification code stored in redis and the input verification code, and deletes the rediskey.
pass the value directly to the server for verification, which can prevent attacks
can be saved in the cache