Exemplo n.º 1
0
        public void Login(Dictionary <string, object> credentialInfo, int handle)
        {
            CheckLaunchingStatusExpire(() =>
            {
                GamebaseCallback.GamebaseDelegate <GamebaseResponse.Auth.AuthToken> providerLoginCallback = (authToken, error) =>
                {
                    string providerName = string.Empty;
                    if (credentialInfo.ContainsKey(GamebaseAuthProviderCredential.PROVIDER_NAME) == true)
                    {
                        providerName = (string)credentialInfo[GamebaseAuthProviderCredential.PROVIDER_NAME];
                    }

                    if (Gamebase.IsSuccess(error) == true)
                    {
                        GamebaseIndicatorReport.SetLastLoggedInInfo(providerName, authToken.member.userId);
                        GamebaseIndicatorReport.SendIndicatorData(
                            GamebaseIndicatorReportType.LogType.AUTH,
                            GamebaseIndicatorReportType.StabilityCode.GB_AUTH_LOGIN_SUCCESS,
                            GamebaseIndicatorReportType.LogLevel.INFO,
                            new Dictionary <string, string>()
                        {
                            { GamebaseIndicatorReportType.AdditionalKey.GB_SUB_CATEGORY1, GamebaseIndicatorReportType.SubCategory.LOGIN },
                            { GamebaseIndicatorReportType.AdditionalKey.GB_LOGIN_IDP, providerName },
                            { GamebaseIndicatorReportType.AdditionalKey.GB_CREDENTIAL, JsonMapper.ToJson(credentialInfo) }
                        });
                    }
                    else
                    {
                        GamebaseIndicatorReport.SendIndicatorData(
                            GamebaseIndicatorReportType.LogType.AUTH,
                            GamebaseIndicatorReportType.StabilityCode.GB_AUTH_LOGIN_CANCELED,
                            GamebaseIndicatorReportType.LogLevel.DEBUG,
                            new Dictionary <string, string>()
                        {
                            { GamebaseIndicatorReportType.AdditionalKey.GB_SUB_CATEGORY1, GamebaseIndicatorReportType.SubCategory.LOGIN },
                            { GamebaseIndicatorReportType.AdditionalKey.GB_LOGIN_IDP, providerName },
                            { GamebaseIndicatorReportType.AdditionalKey.GB_CREDENTIAL, JsonMapper.ToJson(credentialInfo) }
                        },
                            error,
                            true);
                    }

                    var callback = GamebaseCallbackHandler.GetCallback <GamebaseCallback.GamebaseDelegate <GamebaseResponse.Auth.AuthToken> >(handle);

                    if (callback != null)
                    {
                        callback(authToken, error);
                    }

                    GamebaseCallbackHandler.UnregisterCallback(handle);
                };

                int providerLoginHandle = GamebaseCallbackHandler.RegisterCallback(providerLoginCallback);

                LoginWithCredentialInfo(credentialInfo, providerLoginHandle);
            });
        }
Exemplo n.º 2
0
        public virtual void Login(string providerName, int handle)
        {
            CheckLaunchingStatusExpire(() =>
            {
                GamebaseCallback.GamebaseDelegate <GamebaseResponse.Auth.AuthToken> providerLoginCallback = (authToken, error) =>
                {
                    if (Gamebase.IsSuccess(error) == true)
                    {
                        GamebaseIndicatorReport.SetLastLoggedInInfo(providerName, authToken.member.userId);
                        GamebaseIndicatorReport.SendIndicatorData(
                            GamebaseIndicatorReportType.LogType.AUTH,
                            GamebaseIndicatorReportType.StabilityCode.GB_AUTH_LOGIN_SUCCESS,
                            GamebaseIndicatorReportType.LogLevel.INFO,
                            new Dictionary <string, string>()
                        {
                            { GamebaseIndicatorReportType.AdditionalKey.GB_SUB_CATEGORY1, GamebaseIndicatorReportType.SubCategory.LOGIN },
                            { GamebaseIndicatorReportType.AdditionalKey.GB_LOGIN_IDP, providerName }
                        });
                    }
                    else
                    {
                        GamebaseIndicatorReport.SendIndicatorData(
                            GamebaseIndicatorReportType.LogType.AUTH,
                            GamebaseIndicatorReportType.StabilityCode.GB_AUTH_LOGIN_CANCELED,
                            GamebaseIndicatorReportType.LogLevel.DEBUG,
                            new Dictionary <string, string>()
                        {
                            { GamebaseIndicatorReportType.AdditionalKey.GB_SUB_CATEGORY1, GamebaseIndicatorReportType.SubCategory.LOGIN },
                            { GamebaseIndicatorReportType.AdditionalKey.GB_LOGIN_IDP, providerName }
                        },
                            error,
                            true);
                    }

                    var callback = GamebaseCallbackHandler.GetCallback <GamebaseCallback.GamebaseDelegate <GamebaseResponse.Auth.AuthToken> >(handle);

                    if (callback != null)
                    {
                        callback(authToken, error);
                    }

                    GamebaseCallbackHandler.UnregisterCallback(handle);
                };

                int providerLoginHandle = GamebaseCallbackHandler.RegisterCallback(providerLoginCallback);

                LoginWithProviderName(providerName, providerLoginHandle);
            });
        }
Exemplo n.º 3
0
        public void Login(string providerName, Dictionary <string, object> additionalInfo, int handle)
        {
            GamebaseCallback.GamebaseDelegate <GamebaseResponse.Auth.AuthToken> providerLoginCallback = (authToken, error) =>
            {
                if (Gamebase.IsSuccess(error) == true)
                {
                    GamebaseIndicatorReport.SetLastLoggedInInfo(providerName, authToken.member.userId);
                    GamebaseIndicatorReport.SendIndicatorData(
                        GamebaseIndicatorReportType.LogType.AUTH,
                        GamebaseIndicatorReportType.StabilityCode.GB_AUTH_LOGIN_SUCCESS,
                        GamebaseIndicatorReportType.LogLevel.INFO,
                        new Dictionary <string, string>()
                    {
                        { GamebaseIndicatorReportType.AdditionalKey.GB_SUB_CATEGORY1, GamebaseIndicatorReportType.SubCategory.LOGIN },
                        { GamebaseIndicatorReportType.AdditionalKey.GB_LOGIN_IDP, providerName },
                        { GamebaseIndicatorReportType.AdditionalKey.GB_CREDENTIAL, JsonMapper.ToJson(additionalInfo) }
                    });
                }
                else
                {
                    GamebaseIndicatorReport.SendIndicatorData(
                        GamebaseIndicatorReportType.LogType.AUTH,
                        GamebaseIndicatorReportType.StabilityCode.GB_AUTH_LOGIN_CANCELED,
                        GamebaseIndicatorReportType.LogLevel.DEBUG,
                        new Dictionary <string, string>()
                    {
                        { GamebaseIndicatorReportType.AdditionalKey.GB_SUB_CATEGORY1, GamebaseIndicatorReportType.SubCategory.LOGIN },
                        { GamebaseIndicatorReportType.AdditionalKey.GB_LOGIN_IDP, providerName },
                        { GamebaseIndicatorReportType.AdditionalKey.GB_CREDENTIAL, JsonMapper.ToJson(additionalInfo) }
                    },
                        error,
                        true);
                }

                var callback = GamebaseCallbackHandler.GetCallback <GamebaseCallback.GamebaseDelegate <GamebaseResponse.Auth.AuthToken> >(handle);

                if (callback != null)
                {
                    callback(authToken, error);
                }

                GamebaseCallbackHandler.UnregisterCallback(handle);
            };

            int providerLoginHandle = GamebaseCallbackHandler.RegisterCallback(providerLoginCallback);

            if (AuthAdapterManager.Instance.IsSupportedIDP(providerName) == false)
            {
                var callback = GamebaseCallbackHandler.GetCallback <GamebaseCallback.GamebaseDelegate <GamebaseResponse.Auth.AuthToken> >(providerLoginHandle);
                GamebaseErrorNotifier.FireNotSupportedAPI(
                    this,
                    callback,
                    string.Format("LoginWithAdditionalInfo({0})", providerName));
                GamebaseCallbackHandler.UnregisterCallback(providerLoginHandle);
                return;
            }

            if (CanLogin(providerLoginHandle) == false)
            {
                return;
            }

            bool hasAdapter = AuthAdapterManager.Instance.CreateIDPAdapter(providerName);

            if (hasAdapter == false)
            {
                var callback = GamebaseCallbackHandler.GetCallback <GamebaseCallback.GamebaseDelegate <GamebaseResponse.Auth.AuthToken> >(providerLoginHandle);
                callback(null, new GamebaseError(GamebaseErrorCode.AUTH_IDP_LOGIN_FAILED, message: GamebaseStrings.AUTH_ADAPTER_NOT_FOUND_NEED_SETUP));
                GamebaseCallbackHandler.UnregisterCallback(providerLoginHandle);
            }

            AuthAdapterManager.Instance.IDPLogin(additionalInfo, (adapterError) =>
            {
                if (Gamebase.IsSuccess(adapterError) == true)
                {
                    var idPAccessToken = AuthAdapterManager.Instance.GetIDPData <string>(providerName, AuthAdapterManager.MethodName.GET_IDP_ACCESS_TOKEN);
                    var requestVO      = AuthMessage.GetIDPLoginMessage(providerName, idPAccessToken);
                    RequestGamebaseLogin(requestVO, providerLoginHandle);

                    return;
                }

                var callback = GamebaseCallbackHandler.GetCallback <GamebaseCallback.GamebaseDelegate <GamebaseResponse.Auth.AuthToken> >(providerLoginHandle);
                if (callback == null)
                {
                    return;
                }

                GamebaseCallbackHandler.UnregisterCallback(providerLoginHandle);
                callback(null, new GamebaseError(GamebaseErrorCode.AUTH_IDP_LOGIN_FAILED, Domain, error: adapterError));
                AuthAdapterManager.Instance.IDPLogout(providerName);
            });
        }