Scan the QR code to enable one-click logon and one-click Logon

Source: Internet
Author: User

Scan the QR code to enable one-click logon and one-click Logon

The first time I wrote a blog, I was very excited. I didn't know how to write it, so I could easily express it ......

Some time ago, I received a request saying that I would like to add a scan code login function on our project. Just like QQ and QQ, I immediately checked some information online, I felt that it was not the same as our system. After some guidance from some great gods, I finally realized this function.

1. Use your bound account to log on.

Scan the QR code to jump to the page bound to the account. Note that you can only use the scan. to authorize the scan, you need to pass two parameters. One is guid, another one is the id of the account you want to bind. The meanings of these two parameters are: guid can be used to find the computer to bind, because our system, one account can log on to multiple computers at the same time. Id is used to find the account you want to bind. Click "OK" to insert a piece of data to the database. After successful, the account is successfully bound.

2. start logging on

Add a timer to the logon page.

$ (Function () {var interval; // click to display the QR code $ (". login-2wm "). click (function () {$ (". login_formdiv "). toggle (); $ (". A login-2wm span "). toggle (); $ (". login_title p. login_title_p "). toggle (); if (interval = undefined) {interval = setInterval (Qrcode, "3000") ;}); // monitoring function Qrcode () {$. get ('/WxWeb/QRCodeLogin/check', // The link to be verified {guid:' <% = guid %> '// prevents logon errors}, function (res) {if (res. code) {$. post ('.. /tools/QrLogin. ashx', // simulate User Logon for verification {mid: res. MId, // The id guid: res. guid}, function (testData) {if (testData. agentLevel ==- 1000) {$. dialog. alert (testData. description);} else if (testData. agentLevel> 0) {window. location. href = "xxx. aspx ";} else {window. location. href = "xxx. aspx ";}}," JSON ") ;}," JSON ") ;}; </script>

The timer indicates the page for real-time monitoring and verification. After the authentication page is authorized to obtain the openid, It is matched in the database. After the matching is successful, the account id is returned, after I get the parameters I need, I post another request to simulate user logon. This will make the login successful. Is it very easy? The first write is not good. Don't like it!

Related Article

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.