示例#1
0
 /// <summary>
 /// Sign out the currently signed in user.
 /// </summary>
 /// <remarks>
 /// - If no user is currently signed in, callback returns false
 /// </remarks>
 /// <param name="onComplete">Whether the currently signed in user successfully signed out.</param>
 public virtual void Logout(Action <bool> onComplete)
 {
     if (SUGARManager.UserSignedIn)
     {
         SUGARManager.unity.StartSpinner();
         ClearSavedLogin();
         SUGARManager.client.Session.LogoutAsync(
             () =>
         {
             SUGARManager.SetCurrentUser(null);
             SUGARManager.SetCurrentGroup(null);
             SUGARManager.unity.ResetClients();
             SUGARManager.unity.StopSpinner();
             onComplete(true);
         },
             exception =>
         {
             Debug.LogError(exception);
             SUGARManager.unity.StopSpinner();
             onComplete(false);
         });
     }
     else
     {
         onComplete(false);
     }
 }
示例#2
0
        private void PostSignIn(AccountResponse response)
        {
            SUGARManager.unity.StopSpinner();

            if (HasInterface && _interface.RememberLogin)
            {
                if (!string.IsNullOrEmpty(response.LoginToken))
                {
                    SaveLogin(response.LoginToken, response.User.Name);
                }
            }
            else
            {
                ClearSavedLogin();
                // Clear text in the account panel
                if (HasInterface)
                {
                    _interface.ResetText();
                }
            }

            if (SUGARManager.unity.GameValidityCheck())
            {
                SUGARManager.SetCurrentUser(response.User);

                var didGetResources = false;
                var didGetGroups    = false;

                SUGARManager.Resource.StartCheck(
                    () =>
                {
                    didGetResources = true;
                    if (didGetGroups && didGetResources)
                    {
                        _signInCallback(true);
                    }
                });

                SUGARManager.userGroup.GetGroupsList(
                    groups =>
                {
                    SUGARManager.SetCurrentGroup(groups.FirstOrDefault());

                    didGetGroups = true;
                    if (didGetGroups && didGetResources)
                    {
                        _signInCallback(true);
                    }
                });
            }

            Hide();
        }