Flask picture Security Code function

Registration also contains a number of small features: phone number, verification code

 

Image verification code processes:

 

Cause the browser to send a request, when the verification code, the verification bring a name, and to associate this name and a random codes, the character codes stored in the redis (expiration time can be set), and when the user inputs authentication after the code, use the contents of the input and save by comparing the final verify correct

If the validation whole but, on the phone number to send a verification code to start the process.

 

Authentication code generation process: 

UUID is a universally unique identifier: Let the image verification code name for the

 

From the front-end code and then find the img tag, and then set the click event, one point, for once authentication code.

 

When clicked, acquired image src attribute, and then set an onclick event (is a function, in main.js in), and then set a request url = "imag -? Code imagecodeid =" + UUid (automatically generated using generateUUID function , inageuuid = generateUUID ()), then get to the img tag ($ ( ". get_pic_code"). attr ( "src", url)) (attr and prop the same). Finally, clear the cache, reload,

 

Finally disposed at a rear end view corresponding :( function receives the request, generates authentication code)

How authentication code generated using the generated code function :()

    Generating a kit: utils, put info in violence storage

Guess you like

Origin blog.csdn.net/weixin_44786530/article/details/91321463