Offline License Con...
 
Notifications
Clear all

Offline License Control and Login Iteration

3 Posts
2 Users
0 Reactions
1,046 Views
 fau
(@fau)
Posts: 16
Eminent Member
Topic starter
 

Hi Francesco,

I have a question about offline license iteration and offline login features. I am sure you have control for those. But I could not find a way out I would be grateful if you could help me.

Let me explain the process. I want the user to be able to login without server access. For that I can retrieve the last logged-in user. If there is an already logged in user previously I want the user to skip the login page. And If he/she has a limited license like say 5 times maximum, I want to control the entry count when offline. I guess those details are saved within the PlayerPrefs. But is it encrypted? And if you could help me to control these parameters I would be very happy. Right now I can log in if a user exists in the player prefs. But I can not manage the properties passed into it. By the way, the application is designed for Android. I think Unity saves player prefs differently depending on the platform it is running on. I wanted to mention this detail if it makes a difference.

As said I am 100% sure that your framework has methods controlling the already authenticated user and its parameters but I can't seem to generate the best practice to reach this goal. If you could help me achieve this I would be extremely grateful.

With best wishes.

Fau

This topic was modified 6 years ago 2 times by fau
 
Posted : 31/01/2019 9:33 pm
(@skaredcreations)
Posts: 805
Prominent Member Admin
 

If you look at the sample script DemoLicenseManager (lines 166-173) it instantiates a new LicensedUser object setting the username and licenseEncrypted getting them from PlayerPrefs (Username is stored by Combu login if you have enabled "Remember credentials" else you can store it yourself after a successful login; while License is stored few lines later in the same function [usually after a successful login]).

When in offline mode you can retrieve the license's type (for example eLicenseType.Monthly), value (for example: 12-2018) and output (for example: long number of date/time ticks of 31/12/2018) by calling LicenseManager.IsValidLicense like it does in the script LicensedUser.

For example:

  • after a successful login:
PlayerPrefs.SetString("Username", user.userName);
PlayerPrefs.SetString("License", LicenseManager.instance.Encrypt(user.license));
PlayerPrefs.SetString("LicenseNumber", user.licenseNumber);
if (user.licenseIsValid) {
Debug.Log("License is valid: " + user.licenseType + " - value: " + user.licenseValue);
// There's also user.expireDate (if licenseType is Time/Monthly/Yearly) and user.expireLaunch (if licenseType is Launch)
}
  • when offline:
user = new LicensedUser();
user.userName = PlayerPrefs.GetString("Username");
user.licenseEncrypted = PlayerPrefs.GetString("License");
user.licenseNumber = PlayerPrefs.GetString("LicenseNumber");

LicenseManager.eLicenseType licenseType;
string licenseValue, licenseOutput;
if (LicenseManager.IsValidLicense(user.licenseEncrypted, user.userName, out licenseType, out licenseValue, out licenseOutput)) {
Debug.Log("License is valid: " + licenseType + " >> " + licenseValue + " >> " + licenseOutput);
} else {
Debug.Log("License is not valid");
}

I will eventually add an easier method in the near future to automatically do this check and set internal user variables by creating an optional constructor.

FRANCESCO CROCETTI @ SKARED CREATIONS

 
Posted : 31/01/2019 10:44 pm
 fau
(@fau)
Posts: 16
Eminent Member
Topic starter
 

Thank you Francesco for the insightful and rapid reply.

Best regards
Ciao,
Fau

This post was modified 6 years ago by fau
 
Posted : 02/02/2019 12:03 am
Share: