We don't want a player to have to type in their email and password every time they start the game, so for this we can reuse the session token provided by the WhiteLabelLogin call multiple times.
By default a session token is good for 24 hours, but if you send remember me to true a session will last for 30 days. Remember that these sessions are disconnected from the game session, so you still want to create a game session every time the player opens your game.
The length of a remember session can be changed in platform settings for White Label Login.
When a player opens the game we first want to check if they have a previous session we can use:
// Remember to use the LootLocker namespace in the top of your file.usingLootLocker.Requests;LootLockerSDKManager.CheckWhiteLabelSession(response =>{if (response) { // Start a new sessionDebug.Log("session is valid, you can start a game session"); }else { // Show login form hereDebug.Log("session is NOT valid, we should show the login form"); }});
This functionality is not yet implemented in the Unreal SDK
Depending on the response from this code we can either show the login form and ask for email and password again or we can start a game session.
Request Password Reset
If the user wants to reset their password we can use the following example to send them an email with a link to a reset password page.
The page is hosted on LootLocker and will use the settings in Platform Settings for name and logo.
// Remember to use the LootLocker namespace in the top of your file.usingLootLocker.Requests;// This code should be placed in a handler when user clicks reset password.string email ="user@lootlocker.io";LootLockerSDKManager.WhiteLabelRequestPassword(email, (response) =>{if (!response.success) {Debug.Log("error requesting password reset");return; }Debug.Log("requested password reset successfully");});
Above is an example of how to implement password reset for a White Label user using blueprints in Unreal Engine. For an example you can copy and paste into your editor, look here.
Input
You need to exchange the TriggerWhiteLabelResetPasswordevent for whatever event you want to use to trigger the login flow.
You also need to replace the node REPLACE: Input with the users email usually collected from user input.
Output
We recommend branching the completed events on the success flag, and if you do this you will probably want to add error handling in case the request fails as well as what (if any) continued actions you want on success.