LI PASS Login
After initializing the pass component, call the Start method to mount the LI PASS Web component to the designated DOM node.Upon successful login, the login result will be returned in intlSignResp.
After login/registration is successfully completed, the component UI will not change. You need to handle the subsequent logic yourself.For example, store login information in cookies or localStorage, and navigate the UI to the login success page.
To customize the login interactions, see Configure LI PASS Web.
Example
<div id="infinite-pass-component"></div>
const pass = new PassFactory.Pass({
env: "test", // Environment
gameID: xxxxx, // GAME_ID configured in Player Network Console
appID: "", // APP_ID configured in Player Network Console
webID: "", // WEB_ID configured in Player Network Console
});
// Call `start` to mount the Web component to the specified DOM node
// After successful login, the login result is returned by the `onLogin` and `onRegister` events
pass.start("#infinite-pass-component");
// You can listen to the event list and obtain the user's authentication information when the user completes login or registration
pass.on("onLogin", (userInfo) => {
// After the user fails to log in, the 'onLoginError event' will be triggered. The game logic after the user successfully logs in can be handled in the event callback
// For example, redirect to a specific page
console.log(userInfo);
});
pass.on("onRegister", (userInfo) => {
// Logic added after successful registration
// For example, redirect to a specific page
console.log(userInfo);
});
Return parameters
| Parameters | Type | Description |
|---|---|---|
| ret | number | Return code 0: Request succeeded !=0: Request failed, see msg for detailed result description |
| msg | string | Result explanation |
| token | string | User token generated by Player Network SDK Length: 40 bytes. See Token for details. |
| openid | String | Unique identifier for Player Network SDK user Default is a string for a 64-bit unsigned integer, 32-bit is also supported |
| token_expire_time | int64 | Token expiration time Unix time |
| user_name | String | Username for login |
| channel_info | object | Channel information of the current channel. For more information, see Channel Information. |
| del_account_status | number | Account Cancellation Status -1: Query Failed 0: No record of revoking Player Network account cancellation request (including email and phone accounts) 1: Deleted Silent Period 2: Account Cancellation Completed 3: Cancel Account 4: Account Cancellation Failed |
| seq | string | Data Stream Message Sequence |
| first_login | number | Is this the first login Unknown: -1 No: 0 Yes: 1 |
Return Sample
{
birthday: "2000-01",
channel_info:{
account:"wuqinghao@outlook.com",
account_plat_type: 131,
account_type: 1,
channelId: 131
},
del_account_status: 0,
first_login: 0,
msg: "success",
openid: "xxx",
ret: 0,
seq: "1638194026-0180225310-032531-0000292460",
token: "xxx",
token_expire_time: 1638494026,
user_name: "user",
}