Calling localUser a...
 
Notifications
Clear all

Calling localUser after callback

8 Posts
2 Users
0 Reactions
603 Views
(@jshwntr)
Posts: 5
Active Member
Topic starter
 

Hello,

I'm trying to call CombuDemoUser user = (CombuDemoUser)CombuManager.localUser; after a CallWebservice callback, but it's turning up empty. Do you have any tips for what I could do?

After a callback if CombuManager.instance.isAuthenticated is false. Is there a way I can make sure this scope appears after the callback?

Thanks for your help.

Josh

 
Posted : 19/09/2015 12:05 pm
(@skaredcreations)
Posts: 805
Prominent Member Admin
 

Did you use the overload Authenticate<CombuDemoUser>? Else the authentication will instantiate the user object with the standard User class.

FRANCESCO CROCETTI @ SKARED CREATIONS

 
Posted : 19/09/2015 12:08 pm
(@jshwntr)
Posts: 5
Active Member
Topic starter
 

This is an example call that's causing the problem. Is there a way i can have isAuthenticated equal true?

CombuDemoUser user = (CombuDemoUser)CombuManager.localUser;
user.emailInput = "mike@example.com";
user.ResetPassword(user.emailInput, (bool success, string error) => {

    if (CombuManager.instance.isAuthenticated) {
        Debug.Log("true");
    } else {
        Debug.Log("false");
    }

});

 
Posted : 19/09/2015 12:13 pm
(@skaredcreations)
Posts: 805
Prominent Member Admin
 

I don't understand what you're doing, there isn't any non-static overload of ResetPassword that accepts a string and a callback. Also setting the email at runtime without calling Update will have no effect because the reset password email is sent to the email registered on database.

About the casting localUser to CombuDemoUser class will work, as already said, only if you used the overload Authenticate<CombuDemoUser> (take a look at the code here).

Also "isAuthenticated" had an issue that was fixed in version 2.1 that has been just released on this website and sent to Asset Store yesterday (but will take some days to be available there).

FRANCESCO CROCETTI @ SKARED CREATIONS

 
Posted : 19/09/2015 3:04 pm
(@jshwntr)
Posts: 5
Active Member
Topic starter
 

Apologies. I had modified that method and didn't realize it until I read your reply. Really the issue is every callback loses authentication (I had the new isAuthenticated installed). After a callback like the below, a second call to something isn't possible. Do you know a way I can do this? It would help a lot if I could make a second call. Here is an example from the sample application. Thanks much for any help!

textCustom.text = "Loading...";
CombuDemoUser user = (CombuDemoUser)CombuManager.localUser;
user.customData[customKey.text] = customValue.text;
user.Update((bool success, string error) => {
if (CombuManager.instance.isAuthenticated) {
        Debug.Log("true");
    } else {
        Debug.Log("false");
    }
});

 
Posted : 19/09/2015 8:03 pm
(@jshwntr)
Posts: 5
Active Member
Topic starter
 

Wait...there may have been a problem in one of my scripts that was messing things up. I'm doing some testing now.

 
Posted : 19/09/2015 10:10 pm
(@skaredcreations)
Posts: 805
Prominent Member Admin
 

I tried the following and it works, so there should be something else in your other code/scripts that is invalidating the local user:

 

        CombuManager.platform.Authenticate"aa""aa", (bool successstring error) => {

            Debug.Log("First: " + CombuManager.instance.isAuthenticated);
            CombuManager.localUser.customData["test"] = "ok";
            CombuManager.localUser.Update((bool success2string error2) => {
                Debug.Log("Second: " + CombuManager.instance.isAuthenticated);
            });

        });

FRANCESCO CROCETTI @ SKARED CREATIONS

 
Posted : 19/09/2015 10:10 pm
(@jshwntr)
Posts: 5
Active Member
Topic starter
 

Yes, I agree. Thanks for sticking with me. Investigating now why this is happening.

 
Posted : 19/09/2015 10:11 pm
Share: