当前位置:网站首页>Basic process of code scanning login

Basic process of code scanning login

2022-06-23 09:00:00 Spruce cabin

Basic process of code scanning and login

   Abstract : This note mainly records the basic process of code scanning login , Is to learn the basic knowledge of scanning code to log in .

1. The initial state : The mobile terminal is not logged in , Web side not logged in

 Insert picture description here

   In this state, no client is logged in , The personal identification mark filled in by the user only exists in the memory of the mobile phone , That is, it only exists in the login box of the mobile phone , You haven't clicked confirm to submit to the server yet .

2. Mobile terminal login status : Mobile login , Web side not logged in

 Insert picture description here

   At this time, the user logs in on the mobile terminal , That is to say, the mobile terminal submits the login information to the server and successfully logs in , At this point, a memory area is created in the server to record the login status of the user , There is the unique identification information of the user , The server uses this information in this specific space to record the event that the user logs in using the mobile terminal , When this unique user ID code exists in this area , This means that the user has already logged in on the mobile phone .

3. QR code initialization status : At this point, the user opens the web page and selects the QR code to log in

 Insert picture description here

   At this time, the user opens the QR code login page on the web side , This page will request a random QR code from a specific service in the server , The service will generate a unique id No. is assigned to the QR code , There should be a jump target in the QR code url Content , Then the server will pass this information to the client for display on the page , At this time, the client will save a QR code UUID, The server will also save one .

   Two dimensional coded UUID The purpose is to distinguish different QR codes , Because this system is synchronic , At this moment, many users may be trying to scan the code to log in , As shown in the figure below , We want different users to jump to their own pages , A unique... Must be generated for each user's QR code id That is to say UUID, Everyone scans their own code , You will complete your login function :

 Insert picture description here

   More than that , In the QR code tracking service of the server , There is also a field for storing the status of the QR code , It is used to help the front page face the security escort of QR code , There will also be a special js Timer to poll the status value through the interface , And then track the status of the QR code in real time :

[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-I4ZO5798-1655898260138)(https://picgo-img-1303825935.cos.ap-beijing.myqcloud.com/lrbPic/%E6%9C%AA%E5%91%BD%E5%90%8D%E6%96%87%E4%BB%B6(29)]4.jpg)

4. Initial scanning code status of the mobile phone : Cell phones scan QR codes , And got the information of the QR code

 Insert picture description here

   After scanning the code on the mobile phone , You will get the information in the QR code , At this time, the mobile terminal will obtain the data information of the QR code , And jump , First, the mobile phone calls a servlet, This servlet According to the QR code value obtained by the mobile phone in the mobile terminal, it will notify the QR code storage data structure in the QR code status tracking area to change the status , Change from not logged in to logging in , Then the mobile page will jump to a page to confirm login , If the mobile terminal user chooses to confirm login , Will trigger login , Otherwise it will return .

   meanwhile , Front-end js The timer will detect the status change in the background , The QR code will be locked , Forbid others to scan the code , Prevent repeated code scanning .

5. Confirm login status : The phone clicks "confirm login"

 Insert picture description here

   After the user clicks confirm to log in , The mobile terminal will connect the user's ID code with the QR code UUID Transmit it , To a servlet in , This servlet The two-dimensional code UUID Make a match and send the user's id , At this time, the system will query the place where the user login status is stored according to the user's ID , If you confirm that the user already exists , Then retrieve user data from the database , And jump to the web page , Enter the login success page , So far, the QR code login is completed .

6. summary

   The principle of QR code login is basically like this , Its essence is to match the identification codes on both sides , This knowledge is a rough basic process , We must study more deeply when we have time .

原网站

版权声明
本文为[Spruce cabin]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/174/202206230847540079.html