Notifications
Clear all

Custom User class with AuthenticatePlatform

(@sgeorge)
Active Member Registered

Hi all, new here.

Following the steps, I've created a custom class m80User.

I have been using the AuthenticatePlatform call to Auto create a user account and associate it with a combu user. Which works fine. Next step was to add my custom user class <m80User> in this case.

On success, I try to cast CombuManager.localUser as M80User but it remains Null. Am I missing something here? I am sure after I get more familiar with the code base, it will become more apparent but the custom User example I followed is for standard account creation flow. I need to do the same for AuthenticatePlatform flow.

CombuManager.localUser.AuthenticatePlatform<M80User>(platformName, platformID, (bool success, string error) => {
                if (success)
                {
                   
                    Debug.Log("Login success: ID " + CombuManager.localUser.id);
                    M80User user = CombuManager.localUser as M80User;
                    RequestInventoryData();
                }

                else
                {
                    Debug.Log("Login failed: " + error);
                   
                }

 

ReplyQuote
Topic starter Posted : 28/04/2021 8:40 pm
(@skaredcreations)
Prominent Member Admin

You're right, please edit the method AuthenticatePlatform<T> in the Unity script User.cs inside the callback after the check on success (it should be lines 1021-1022) and change it to this:

_authenticated = true;
T user = new T ();
user.FromJson(result["message"].ToString());
CombuManager.instance.SetLocalUser(user);

This change will be applied to the next incoming update as well, thank you for the report.

FRANCESCO CROCETTI @ SKARED CREATIONS

ReplyQuote
Posted : 30/04/2021 9:46 am
(@sgeorge)
Active Member Registered

@skaredcreations

Correct me if I am wrong but I think it should be like this, otherwise Authenticated will always be false.

T user = new T();
user._authenticated = true;
user.FromJson(result["message"].ToString());
CombuManager.instance.SetLocalUser(user);
ReplyQuote
Topic starter Posted : 30/04/2021 6:44 pm
(@skaredcreations)
Prominent Member Admin

@sgeorged yes indeed 😎 

FRANCESCO CROCETTI @ SKARED CREATIONS

ReplyQuote
Posted : 30/04/2021 7:26 pm
Share: