How to implement javascript-web QR code logon

Source: Internet
Author: User
Recently, I am working on a web instant messaging service, which provides a code scanning logon function. I have never done it before. I 'd like to ask some experts to talk about it. For example, if the QR code is successfully scanned by the mobile phone and the data sent by the server is being sent by the web client, a web instant messaging function is available in the web client. I have never done it before. I 'd like to ask some experts to talk about it.
For example, if the QR code is successfully scanned by the mobile phone, the web client sends data to the server.

Reply content:

Recently, I am working on a web instant messaging service, which provides a code scanning logon function. I have never done it before. I 'd like to ask some experts to talk about it.
For example, if the QR code is successfully scanned by the mobile phone, the web client sends data to the server.

Step 3: Scan the QR code in step 3 of the WEB platform mobile phone to generate a QR code in step 2 (ajax monitoring background) and confirm the code (the background asynchronously notifies the WEB platform). Step 3: ajax detects the status change, login successful

Ajax monitoring background process: After the QR code is generated,

SetTimeout (function () {// AJAX request, Check Status}, 5000 );

The upstairs is correct. Let me add it.
Example
Solve two problems: <1> check whether someone scanned my computer from the server and authorize logon.
Then, the app wants to solve the problem: after scanning, it knows who the scan is and tells the user information to the server.
Object <1> website <2> open on mobile phone

Process
<1> web-generated links are used as two-dimensional codes. Generally, local cookies or sessionid are used as unique parameters.

<2> after the app is scanned, authorization is performed to capture user information and store the cookies or sessionids contained in user information and requests to the database.
<3> the backend of the ajax request every few seconds to query whether the current cookies or sessionid have the corresponding logon information.

1. the front-end calls the API for generating the QR code in the background to obtain the QR code image and the information contained (usually a unique ID)
2. check whether the front-end has a mobile phone scan code (by polling or websock, and by calling the background API, the parameter is the unique ID above.
3. scan the QR code to log on to the mobile phone. the mobile phone can obtain the information ID in the QR code and call the background interface with the ID in the current login user ID and QR code.
The background stores the data of this QR code and adds the login user information. when the current station calls the API, the login is successful.
4. jump to the front-end when the logon is successful.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.