コード例 #1
0
        /// <summary>
        /// User Login
        /// </summary>
        /// <param name="username"></param>
        /// <param name="password"></param>
        /// <param name="eventName"></param>
        public static void Login(string username, string password, string eventName)
        {
            Debug.Log("Authentication...");

            var loginRequest = new AuthenticationRequest();

            loginRequest.SetUserName(username);
            loginRequest.SetPassword(password);

            loginRequest.Send(response =>
            {
                if (!response.HasErrors)
                {
                    Debug.Log("Player authenticated! \n Name: " + response.DisplayName);

                    EventManager.TriggerEvent(eventName, response.DisplayName);

                    IsUserLoggedIn = true;
                }
                else
                {
                    Debug.Log("Error authenticating player... \n" + response.Errors.JSON.ToString());

                    EventManager.TriggerEvent(eventName, "");
                }
            });
        }
コード例 #2
0
    public void Login()
    {
        AuthenticationRequest user = new AuthenticationRequest();

        user.SetUserName(UserNameInput.text);
        user.SetPassword(PasswordInput.text);

        user.Send((respone) => {
            // Login operation done (fail or success), handling it:
            if (!respone.HasErrors)
            {
                // Login successful
                Debug.Log("Welcome " + respone.DisplayName);
                SceneManager.LoadScene(0);
            }
            else if (respone.Errors.JSON.ToString().Contains("UNRECOGNISED"))
            {
                StartCoroutine(Mammad("Username or Password is wrong."));
            }
            else
            {
                Debug.Log(respone.Errors.JSON.ToString());
            }
        });

        new LogEventRequest().SetEventKey("USER_INF").SetEventAttribute("USERNAME", UserNameInput.text).Send((respone) => {
            if (respone.HasErrors)
            {
                print(respone.Errors.JSON.ToString());
            }
        });
    }
コード例 #3
0
    private void Login()
    {
        AuthenticationRequest request = new AuthenticationRequest();

        request.SetUserName(userNameInput.text);
        request.SetPassword(passwordInput.text);
        request.Send(OnLoginSuccess, OnLoginError);
    }
コード例 #4
0
    public void LoginFromReconnect()
    {
        AuthenticationRequest request = new AuthenticationRequest();

        request.SetUserName(GameSparksUserID.currentUsername);
        request.SetPassword(GameSparksUserID.currentPassword);
        request.Send(OnLoginReconnectSuccess, OnLoginReconnectError);
    }
コード例 #5
0
    public void OnClickLogin()
    {
        BlockInput();
        AuthenticationRequest request = new AuthenticationRequest();

        request.SetUserName(inputFieldUserName.text);
        request.SetPassword(inputFieldPassword.text);
        request.Send(OnLoginSuccess, OnLoginError);
    }
コード例 #6
0
    private void LoginAsAdmin()
    {
        BlockLoginInput();
        AuthenticationRequest request = new AuthenticationRequest();

        request.SetUserName(adminUsername);
        request.SetPassword(adminPassword);
        request.Send(OnAdminLoginSuccess, OnLoginError);
    }
コード例 #7
0
ファイル: LoginPanel.cs プロジェクト: adel12790/Gomoku
    private void Login()
    {
        BlockInput();
        AuthenticationRequest request = new AuthenticationRequest();

        request.SetUserName(userNameInput.text);
        request.SetPassword(passwordInput.text);
        request.Send(OnLoginSuccess, OnLoginError);
        Debug.Log("Login Request: " + request.JSONString);
    }
コード例 #8
0
        public void NewPasswordLogin()
        {
            DataController.SaveValue("password", password.text);

            Debug.Log(password.text);

            var loginRequest = new AuthenticationRequest();

            GameSparks.Core.GSRequestData data = new GameSparks.Core.GSRequestData();

            data.AddString("password", DataController.GetValue <string>("password"));

            data.AddString("action", "resetPassword");

            data.AddString("token", token.text);

            loginRequest.SetScriptData(data);

            loginRequest.SetUserName(DataController.GetValue <string>("username"));

            loginRequest.SetPassword(password.text);

            loginRequest.Send(response =>
            {
                if (response.Errors.GetString("action").Contains("complete"))
                {
                    Warning.SetActive(true);

                    PopUpMessage.ActivatePopUp(delegate {  }, LocalisationSystem.GetLocalisedValue("resetpasswordwarning5"));

                    UIController.SetActivePanel(UI_Element.Login);
                }

                if (response.Errors.GetString("action").Contains("invalid"))
                {
                    Warning.SetActive(true);

                    PopUpMessage.ActivatePopUp(delegate { }, LocalisationSystem.GetLocalisedValue("resetpasswordwarning4") + LocalisationSystem.GetLocalisedValue("password_error"));

                    UIController.SetActivePanel(UI_Element.ConfirmResetPassword);
                }


                Debug.Log("well done " + response.Errors.JSON.ToString());

                if (!response.HasErrors)
                {
                    Debug.Log("Error reseting password.../n" + response.Errors.JSON.ToString());
                }
            });
        }
コード例 #9
0
        public static void AuthenticateUser(string userName, string password,
                                            Action <RegistrationResponse> regCallback,
                                            Action <AuthenticationResponse> authCallback)
        {
            // fill pregistration request data
            var regRequest = new RegistrationRequest();

            regRequest.SetDisplayName(userName);
            regRequest.SetUserName(userName);
            regRequest.SetPassword(password);

            regRequest.Send(regResponse =>
            {
                if (regResponse == null)
                {
                    Debug.Log("GSM| GameSparks non initialized.");
                }
                else if (!regResponse.HasErrors)
                {
                    Debug.Log("GSM| Registration Successful...");
                    regCallback?.Invoke(regResponse);
                }
                else
                {
                    if (regResponse.NewPlayer.GetValueOrDefault() == false)
                    {
                        var authRequest = new AuthenticationRequest();
                        authRequest.SetUserName(userName);
                        authRequest.SetPassword(password);

                        authRequest.Send(authResponse =>
                        {
                            if (authResponse.HasErrors == false)
                            {
                                Debug.Log("Authentication Successful...");
                                authCallback(authResponse);
                            }
                            else
                            {
                                Debug.LogWarning("GSM| Error Authenticating User \n" + authResponse.Errors.JSON);
                            }
                        });
                    }
                    else
                    {
                        Debug.LogWarning("GSM| Error Authenticating User \n" + regResponse.Errors.JSON);
                    }
                }
            });
        }
コード例 #10
0
    // Login/Registration
    public void Login(string username, string password)
    {
        BlockLoginInput();
        GameSparksManager gsm = GameObject.Find("GameSparksManager").GetComponent <GameSparksManager>();

        gsm.CheckInternetConnection();

        GameSparksUserID.currentUsername = username;
        GameSparksUserID.currentPassword = password;
        AuthenticationRequest request = new AuthenticationRequest();

        request.SetUserName(username);
        request.SetPassword(password);
        request.Send(OnLoginSuccess, OnLoginError);
    }
コード例 #11
0
    public void Login(string userName, string password)
    {
        AuthenticationRequest request = new AuthenticationRequest().SetUserName(userName).SetPassword(password);

        request.Send((response) =>
        {
            if (response.HasErrors)
            {
                Debug.Log("AuthenticationRequest HasErrors");
            }
            else
            {
                Debug.Log("AuthenticationRequest Success");
                SetUser(response.DisplayName);
            }
        });
    }
コード例 #12
0
    private void OnRegistration(RegistrationResponse response)
    {
        if (response.HasErrors)
        {
            if (response.NewPlayer != true)
            {
                var request = new AuthenticationRequest();

                request.SetUserName(inputField.text);
                request.SetPassword(passwordField.text);
                request.Send(OnAuthentication);

                Debug.LogWarning("GSM| Existing User, Switching to Authentication");
            }
            else
            {
                Debug.LogWarning("GSM| Error Registration User" + response.Errors.JSON);
            }

            return;
        }

        OnRegistrationComplete();
    }
コード例 #13
0
        /// <summary>
        /// User Login
        /// </summary>>
        /// <param name="username"></param>
        /// <param name="password"></param>
        /// <param name="eventName"></param>
        public static void Login(string username, string password, string eventName)
        {
            if (DataController.GetValue <string>("LastValidusername") != username)
            {
                if (DataController.GetValue <string>("LastValidusername") != "")
                {
                    Login(DataController.GetValue <string>("LastValidusername"), DataController.GetValue <string>("LastValidPassword"), null);
                }
            }

            DataController.SaveValue("username", username);

            StatsList = new List <long>();

            EquipmentList = new List <long>();

            OtherStuffList = new List <long>();

            StatsList = new List <long>();

            EquipmentList = new List <long>();

            PrimaryStuffList = new List <long>();

            if (DataController.GetValue <int>("Rating") >= 0)
            {
                var newRequest = new GameSparks.Api.Requests.LogEventRequest();// DataController.GetValue<int>("Rating"));

                newRequest.SetEventKey("RATING_UPDATE").SetEventAttribute("Rating", DataController.GetValue <int>("Rating")).Send(response =>
                {
                });
            }

            var newRequest1 = new GameSparks.Api.Requests.LeaderboardDataRequest();

            newRequest1.SetLeaderboardShortCode("LeaderboardRating").SetEntryCount(35).Send(response =>
            {
                Debug.Log(response.BaseData.JSON);

                LeaderBoardsScript.Ranks = new List <long?>();

                LeaderBoardsScript.Names = new List <string>();

                LeaderBoardsScript.Ratings = new List <long?>();

                foreach (var gd in response.BaseData.GetGSDataList("data"))
                {
                    LeaderBoardsScript.Ranks.Add(gd.GetLong("rank"));

                    LeaderBoardsScript.Names.Add(gd.GetString("userName"));

                    LeaderBoardsScript.Ratings.Add(gd.GetLong("Rating"));

                    //Debug.Log(gd.GetString("userName"));

                    //Debug.Log(gd.GetLong("Rating"));
                }
            });

            Debug.Log("Authentication...");
            var loginRequest = new AuthenticationRequest();


            GameSparks.Core.GSRequestData data = new GameSparks.Core.GSRequestData();
            if (DataController.GetValue <int>("GSNotSynced" + username) > 0 && DataController.GetValue <string>("LastValidusername") == username)
            {
                foreach (string attr in ServerNamz)
                {
                    Debug.Log(DataController.GetValue <int>(attr + "Mine"));
                    StatsList.Add((long)DataController.GetValue <int>(attr + "Mine"));
                }
                data.AddNumberList("Stats", StatsList);

                foreach (string TypeItem in Equipment.ForInvLoad)
                {
                    foreach (string Name in EquipmentNames)
                    {
                        EquipmentList.Add((long)DataController.GetValue <int>(Name + TypeItem + "ammount"));
                    }
                }
                data.AddNumberList("Equipment", EquipmentList);

                int tempNum = 0;

                foreach (int num in CelebrationAnimation.Prices)
                {
                    Debug.Log(num);

                    if (DataController.GetValue <int>("WinAnimNumberMine" + tempNum + "ammount") > 0)
                    {
                        OtherStuffList.Add(1);
                    }
                    else
                    {
                        OtherStuffList.Add(0);
                    }
                    tempNum += 1;
                }

                PrimaryStuffList.Add(DataController.GetValue <int>("Exp"));

                PrimaryStuffList.Add(DataController.GetValue <int>("Bread"));

                PrimaryStuffList.Add(DataController.GetValue <int>("SkillPoints"));

                PrimaryStuffList.Add(DataController.GetValue <int>("Rating"));

                Debug.Log(DataController.GetValue <int>("SkillPoints"));

                data.AddNumberList("OtherStuffList", OtherStuffList);

                data.AddNumberList("PrimaryStuffList", PrimaryStuffList);
            }

            loginRequest.SetUserName(username);
            loginRequest.SetPassword(password);
            loginRequest.SetScriptData(data);


            loginRequest.Send(response =>
            {
                if (!response.HasErrors)
                {
                    GameSparks.Core.GSData GSList = response.ScriptData;
                    foreach (string atributeName in ServerNamz)
                    {
                        DataController.SaveValue(atributeName + "Mine", (int)GSList.GetInt(atributeName));
                    }
                    foreach (string TypeItem in Equipment.ForInvLoad)
                    {
                        foreach (string Name in EquipmentNames)
                        {
                            if (GSList.GetGSData("BoughtOrNot").ContainsKey(Name + TypeItem))
                            {
                                if (GSList.GetGSData("BoughtOrNot").GetInt(Name + TypeItem) > 0)
                                {
                                    DataController.SaveValue(Name + TypeItem + "ammount", 1);
                                }
                                else
                                {
                                    DataController.SaveValue(Name + TypeItem + "ammount", 0);
                                }
                            }
                            else
                            {
                                DataController.SaveValue(Name + TypeItem + "ammount", 0);
                            }
                        }
                    }
                    foreach (var vg in GSList.GetGSDataList("VirtualGoodsList"))
                    {
                        foreach (string modifier in EqModifiers)
                        {
                            if (vg.GetGSData("currencyCosts").GetInt(modifier) != null)
                            {
                                DataController.SaveValue(vg.GetString("name") + modifier, (int)vg.GetGSData("currencyCosts").GetInt(modifier));
                                //Debug.Log(vg.GetString("name"));
                            }
                        }
                        //Debug.Log(vg.GetString("name"));
                        DataController.SaveValue(vg.GetString("name") + "Price", (int)vg.GetGSData("currencyCosts").GetInt("Bread"));
                        DataController.SaveValue(vg.GetString("name") + "SellPrice", (int)vg.GetGSData("currencyCosts").GetInt("BreadPrice"));
                    }

                    int tempNum = 0;
                    long?value  = GSList.GetLong("Anim" + tempNum);
                    while (value != null)
                    {
                        DataController.SaveValue("WinAnimNumberMine" + tempNum + "ammount", (int)value);
                        tempNum += 1;
                        value    = GSList.GetLong("Anim" + tempNum);
                    }

                    for (int i = tempNum; i < CelebrationAnimation.Prices.Count; i++)
                    {
                        DataController.SaveValue("WinAnimNumberMine" + i + "ammount", 0);
                    }

                    long?Exp = GSList.GetLong("TotalExp");
                    DataController.SaveValue("Exp", (int)Exp);

                    long?Bread = GSList.GetLong("TotalBread");
                    DataController.SaveValue("Bread", (int)Bread);

                    long?SkillPoints = GSList.GetLong("TotalSkillPoints");
                    DataController.SaveValue("SkillPoints", (int)SkillPoints);

                    long?Rating = GSList.GetLong("Rating");
                    DataController.SaveValue("Rating", (int)Rating);

                    Debug.Log(DataController.GetValue <int>("SkillPoints"));


                    DataController.SaveValue("GSNotSynced" + username, 0);
                    Debug.Log("Player authenticated! \n Name:" + response.DisplayName + response.ScriptData.JSON);// + response.ScriptData);//.ScriptData.JSON.ToString());


                    IsUserLoggedIn = false;

                    EventManager.TriggerEvent(eventName, response.DisplayName);

                    DataController.SaveValue("LastValidPassword" + username, password);

                    DataController.SaveValue("LastValidusername", username);
                }
                else
                {
                    ResetPassword.instance.Warning.SetActive(true);

                    PopUpMessage.ActivatePopUp(delegate { UIController.SetActivePanel(UI_Element.Login); }, LocalisationSystem.GetLocalisedValue("loginerror1"));

                    Debug.Log("Error authenticating player.../n" + response.Errors.JSON.ToString());

                    EventManager.TriggerEvent(eventName, "");
                }
            });
        }
コード例 #14
0
        public void GetToken()
        {
            DataController.SaveValue("username", username.text);

            var loginRequest = new AuthenticationRequest();

            GameSparks.Core.GSRequestData data = new GameSparks.Core.GSRequestData();

            data.AddString("action", "passwordRecoveryRequest");

            data.AddString("email", email.text);

            loginRequest.SetScriptData(data);

            loginRequest.SetUserName(DataController.GetValue <string>("username"));

            loginRequest.SetPassword("");

            loginRequest.Send(response => {
                if (!response.HasErrors)
                {
                    Warning.SetActive(true);

                    Warning.GetComponentsInChildren <Button>()[1].gameObject.SetActive(false);

                    PopUpMessage.ActivatePopUp(delegate { UIController.SetActivePanel(UI_Element.ConfirmResetPassword); }, LocalisationSystem.GetLocalisedValue("resetpasswordwarning1"));
                }
                else
                {
                    Debug.Log("Error authenticating player.../n" + response.Errors.JSON.ToString());

                    Debug.Log(response.Errors.GetString("action"));

                    if (response.Errors.ContainsKey("action"))
                    {
                        Warning.SetActive(true);

                        //Warning.GetComponentsInChildren<Button>()[1].gameObject.SetActive(false);

                        if (response.Errors.GetString("action").Contains("complete"))
                        {
                            Debug.Log("warn1");

                            UIController.SetActivePanel(UI_Element.ConfirmResetPassword);

                            PopUpMessage.ActivatePopUp(delegate { UIController.SetActivePanel(UI_Element.ConfirmResetPassword); }, LocalisationSystem.GetLocalisedValue("resetpasswordwarning1"));
                        }
                        else if (response.Errors.GetString("action").Contains("email") || response.Errors.GetString("action").Contains("invalid"))
                        {
                            Debug.Log("warn2");

                            PopUpMessage.ActivatePopUp(delegate { UIController.SetActivePanel(UI_Element.ResetPassword); }, LocalisationSystem.GetLocalisedValue("resetpasswordwarning2"));
                        }
                        else
                        {
                            Debug.Log("exception");
                        }
                    }
                }
            });
        }