Пример #1
0
        public void Authenticate(AuthKeys authKeys = null)
        {
            if (AuthType == AuthTypes.None)
            {
                if (OnDisplayAuthentication != null)
                {
                    OnDisplayAuthentication.Invoke();
                }

                return;
            }

            if (RememberMe && !string.IsNullOrEmpty(RememberMeId))
            {
                PlayFabClientAPI.LoginWithCustomID(new LoginWithCustomIDRequest
                {
                    CustomId = RememberMeId,
                    InfoRequestParameters = InfoRequestParams,
                    CreateAccount         = true
                }, InvokeLoginSuccess, InvokePlayFabError);
                return;
            }

            var auth = _authStrategies[AuthType];

            auth.Authenticate(this, resultCallback =>
            {
                // Store Identity and session
                AuthenticationContext = resultCallback.AuthenticationContext;

                // Note: At this point, they already have an account with PlayFab using a Username (email) & Password
                // If RememberMe is checked, then generate a new Guid for Login with CustomId.
                if (RememberMe && string.IsNullOrEmpty(RememberMeId))
                {
                    //Fire and forget, but link a custom ID to this PlayFab Account.
                    PlayFabClientAPI.LinkCustomID(new LinkCustomIDRequest
                    {
                        CustomId              = GetOrCreateRememberMeId(),
                        ForceLink             = ForceLink,
                        AuthenticationContext = AuthenticationContext
                    }, null, null);
                }
                InvokeLoginSuccess(resultCallback);
            }, InvokePlayFabError, authKeys);
        }
Пример #2
0
        public void Unlink(AuthKeys authKeys)
        {
            if (!IsClientLoggedIn())
            {
                InvokeUnlink(authKeys.AuthType, new PlayFabError
                {
                    Error        = PlayFabErrorCode.NotAuthorized,
                    ErrorMessage = "You must log in before you can call Unlink."
                });
                return;
            }

            var auth = _authStrategies[authKeys.AuthType];

            if (auth == null)
            {
                Debug.LogError("Unhandled unlink type: " + authKeys.AuthType);
                return;
            }

            auth.Unlink(this, authKeys);
        }
Пример #3
0
 /// <summary>
 /// Kick off the authentication process by specific authType.
 /// </summary>
 /// <param name="authType"></param>
 /// <param name="authKeys"></param>
 public void Authenticate(AuthTypes authType, AuthKeys authKeys = null)
 {
     AuthType = authType;
     Authenticate(authKeys);
 }