How to make the website quickly have the login and registration function

Recommended website LuckyCola for essential front-end tools (free picture bed, API, chatAI, etc.):
https://luckycola.com.cn/

1. Product introduction

  • Developing a set of login and registration functions by yourself is time-consuming, labor-intensive and costly. Here is how to access the " Open Login Platform ", so that your website can quickly have a powerful login and registration function without development.
  • " LuckyCola Open Login Platform " is a stable and efficient, development-free, multi-functional and stable login system, which can be connected to websites or h5 applications on PC and mobile terminals
    Insert image description here

2. Start using

Important note: It is recommended to use https protocol for all requests. When https protocol cannot be used, try to use http protocol.

1. How to determine whether the user is logged in?

In business scenarios that require user login, we need to first determine whether the current user has logged in? If not logged in, guide the user to log in

"Login Platform " provides an API for "detecting user login status":

请求方式: GET
请求参数:无需参数
http(s)://luckycola.com.cn/checkLoginStatus

Return examples and instructions:

{
    
     
 	// 接口请求成功
     code: 0,
 	// 登录状态提示
     msg: '已登录,登录态有效'  或 ’未登录或登录态无效',
	 // 用户登录状态 值是0或1 ,1表示用户已经登录 0表示用户未登录
      status: 1
}

When it is detected through the API that the user is not logged in, you can display a "login portal" in your application to guide the user to log in.

2. How to let users log in?

When you display the "login entry" to guide the user to log in, the user clicks on the "entry", and you can jump to ""Open Login Platform"" through the Url

Note: The Url configuration for jumping to ""Open Login Platform"" is as follows:

// 跳转开放登录平台的url 
// 注意 u参数必须进行encodeURIComponent()编码处理,并且跳转域名需要申请加入白名单否则无法携带用户信息
http(s)://luckycola.com.cn/public/dist/#/allLoginPage?u=encodeURIComponent(登录成功后的回跳地址)

Parameter Description:

serial number parameter Is it necessary illustrate
1 u yes The callback address that jumps after login. After successful login, user parameters will be spliced ​​on this url (please encodeURIComponent for this url) processing

for example:

If my website address is " http://test.com ", I need to guide users to log in, just jump directly to the address of "login to open platform" below (note: u is processed by encodeURIComponent)

https://luckycola.com.cn/public/dist/#/allLoginPage?u=http%3A%2F%2Ftest.com

After successfully jumping to " "Open Login Platform" ", users can choose their own login method or register.

3. How to get user data after successful login?

When the user completes the login on " Open Login Platform ", the platform will automatically jump back to your callback address (u parameter), and splicing " login status ", " username " and so on on your callback address

Parameters, the specific parameters are as follows

serial number parameter illustrate
1 isLoginOk Whether the user login is successful, the value is 1 or 0 (1 means success, 0 means failure)
2 uid The unique ID of the logged in user. You can store this ID yourself to handle more business scenarios.
3 usrname Username of the logged in user
4 userInfoUrl View the url address of more information about the logged-in user

For example:
If I jump to "Login to the Open Platform" through the following URL

https://luckycola.com.cn/public/dist/#/allLoginPage?u=http%3A%2F%2Ftest.com

And if the user logs in successfully, then the callback address that jumps back to you is as follows:

http://test.com?isLoginOk=1&uid=(用户唯一标识)&usrname=(用户名称)&userInfoUrl=(经过encodeURIComponent后的查看用户信息的地址)

So on your website or application, just get these parameters on the URL

4. How to maintain the user’s login status?

After the user logs in successfully, you can obtain the relevant information of the user and maintain the login status by yourself. At the same time, you can check the user login status through the API. The login status of "Login Open Platform" is kept for 15 days. If the login status expires, boot again Users can log in

"Login Open Platform" also provides an API to actively log out:

请求方式: GET
参数: cuid(用户id,前往官网http://luckycola.com.cn个人中心获取)
https://luckycola.com.cn/user/logout?cuid=12..

2. Points to note

1. In consideration of security, if you need to access the "Open Login Platform" , please log in to the official website of LuckCola , enter [ Personal Center ] and click [ Open Login Platform Domain Name Application ] to apply, and the platform will reply by email to the application result Access and use it~


Say important things three times

  • The domain name of the u parameter jump address needs to apply to be added to the whitelist, otherwise it cannot carry user information.
  • The domain name of the u parameter jump address needs to apply to be added to the whitelist, otherwise it cannot carry user information.
  • The domain name of the jump address of the u parameter needs to apply to join the whitelist, otherwise the user information cannot be carried
    [ Personal Center ]----[ Open login platform domain name application ]----apply
    Insert image description here

Guess you like

Origin blog.csdn.net/qq_48896417/article/details/131575661