Exemple #1
0
        public static void TwoFactorAuthVerification(LootLockerTwoFactorAuthVerficationRequest data, Action <LootLockerAuthResponse> onComplete)
        {
            string json = "";

            if (data == null)
            {
                return;
            }
            else
            {
                json = JsonConvert.SerializeObject(data);
            }

            EndPointClass endPoint = LootLockerEndPoints.current.twoFactorAuthenticationCodeVerification;

            LootLockerServerRequest.CallAPI(endPoint.endPoint, endPoint.httpMethod, json, (serverResponse) =>
            {
                var response = new LootLockerAuthResponse();
                if (string.IsNullOrEmpty(serverResponse.Error))
                {
                    response      = JsonConvert.DeserializeObject <LootLockerAuthResponse>(serverResponse.text);
                    response.text = serverResponse.text;

                    LootLockerConfig.current.UpdateToken(response.auth_token);

                    onComplete?.Invoke(response);
                }
                else
                {
                    response.message = serverResponse.message;
                    response.Error   = serverResponse.Error;
                    onComplete?.Invoke(response);
                }
            }, useAuthToken: false, callerRole: LootLocker.LootLockerEnums.LootLockerCallerRole.Admin);
        }
Exemple #2
0
        void FinalAuth(LootLockerAuthResponse response)
        {
            if (TwoFATockenTimoutCo != null)
            {
                EditorCoroutineUtility.StopCoroutine(TwoFATockenTimoutCo);
            }

            PopulateGames();

            //Fill in organization IDs
            for (int i = 0; i < response.user.organisations.Length; i++)
            {
                organizationIDs.Add(response.user.organisations[i].id.ToString());
            }
        }
        public static void InitialAuthenticationRequest(LootLockerInitialAuthRequest data, Action <LootLockerAuthResponse> onComplete)
        {
            string json = "";

            if (data == null)
            {
                return;
            }
            else
            {
                json = JsonConvert.SerializeObject(data);
            }

            EndPointClass endPoint = LootLockerEndPointsAdmin.current.initialAuthenticationRequest;

            LootLockerServerRequest.CallAPI(endPoint.endPoint, endPoint.httpMethod, json, (serverResponse) =>
            {
                var response = new LootLockerAuthResponse();
                if (string.IsNullOrEmpty(serverResponse.Error))
                {
                    response = JsonConvert.DeserializeObject <LootLockerAuthResponse>(serverResponse.text);

                    if (response.mfa_key == null)
                    {
                        LootLockerAdminConfig.current.UpdateToken(response.auth_token, "");
                    }

                    response.text = serverResponse.text;

                    LootLockerAdminConfig.current.email = data.email;

                    LootLockerAdminConfig.current.password = data.password;

                    onComplete?.Invoke(response);
                }
                else
                {
                    response.message = serverResponse.message;
                    response.Error   = serverResponse.Error;
                    onComplete?.Invoke(response);
                }
            }, useAuthToken: false, callerRole: LootLocker.LootLockerEnums.LootLockerCallerRole.Admin);
        }
Exemple #4
0
        private void LoginAndCreateGame(LootLockerAuthResponse response)
        {
            int organisationID = response.user.organisations.FirstOrDefault().id;

            AppManager.activeOrganisationID = organisationID;
            ///lets try to find the demo game from the list of games coming from the server
            LootLockerGame demoGame = response.user.organisations.FirstOrDefault()?.games?.FirstOrDefault(x => x.is_demo == true);

            //if we found one, lets set the config up
            if (demoGame != null)
            {
                Debug.Log("There's already a Demo Game. Moving on.");
                AppManager.activeGameID         = demoGame.id;
                LootLockerConfig.current.gameID = demoGame.id;
                ///Lets pull more information about the game
                LootLockerSDKManager.GetDetailedInformationAboutAGame(LootLockerConfig.current.gameID.ToString(), (createGameResponse) =>
                {
                    if (createGameResponse.success)
                    {
                        //update the config of the game
                        LootLockerConfig.current.UpdateAPIKey(createGameResponse.game.game_key);
                        successScreen.SetActive(true);
                        activatingScreen.SetActive(false);
                    }
                    else
                    {
                        activatingScreen.SetActive(false);
                        carouselScreen.SetActive(true);
                        normalLoginContent.SetActive(false);
                        failedLoginContent.SetActive(true);
                    }
                });
            }
            else
            {
                //There's no "Demo Game". Create it.
                Debug.LogWarning("No game called Demo Game. Creating one...");
                LootLockerSDKManager.CreatingAGame("Demo Game", "0", true, organisationID, true, (createGameResponse) =>
                {
                    //we were succesful in creating a demo game
                    if (createGameResponse.success)
                    {
                        Debug.Log("Successful created a demo game: " + createGameResponse.text);
                        AppManager.activeGameID         = createGameResponse.game.id;
                        LootLockerConfig.current.gameID = createGameResponse.game.id;
                        LootLockerSDKManager.GetDetailedInformationAboutAGame(LootLockerConfig.current.gameID.ToString(), (createGameResponses) =>
                        {
                            if (createGameResponses.success)
                            {
                                LootLockerConfig.current.UpdateAPIKey(createGameResponses.game.game_key);
                                successScreen.SetActive(true);
                                activatingScreen.SetActive(false);
                            }
                            else
                            {
                                activatingScreen.SetActive(false);
                                carouselScreen.SetActive(true);
                                normalLoginContent.SetActive(false);
                                failedLoginContent.SetActive(true);
                            }
                        });
                    }
                    else
                    {
                        activatingScreen.SetActive(false);
                        carouselScreen.SetActive(true);
                        normalLoginContent.SetActive(false);
                        failedLoginContent.SetActive(true);
                    }
                });
            }
        }