/// <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);
     }
 }
        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();
        }
        private void SignIn()
        {
            if (!Application.isEditor)
            {
                options = CommandLineUtility.ParseArgs(Environment.GetCommandLineArgs());
            }
            if (options != null && options.AuthenticationSource == null)
            {
                options.AuthenticationSource = _defaultSourceToken;
            }

            if (options != null && _allowAutoLogin && options.AutoLogin)
            {
                // Default remember me to false for auto logging in
                LoginUser(options.UserId, options.Password ?? string.Empty, options.AuthenticationSource);
            }
            else
            {
                if (HasInterface)
                {
                    _interface.Display();
                    if (HasSavedLogin)
                    {
                        _interface.SetTokenText(savedUsername);
                    }
                }
                else
                {
                    _signInCallback(false);
                }
            }
            _allowAutoLogin = false;

            if (options != null)
            {
                SUGARManager.SetClassId(options.ClassId);
            }
        }