/// <summary> /// /// </summary> private void OnAuthenticated(CustomAuthCredentials credentials, LoginUserInfo info) { SetPlayAsGuestButtonActive(false); SetLogText("Sign In success!"); //detect if this account is banned before load next level if (bl_LoginProDataBase.Instance.DetectBan && Ban.CheckBanAccount(info.LoginName)) { return; } //if it's OK, load next level of show continue menu isLogin = true; OnLogin?.Invoke(); //check if session has to be remember if (bl_LoginProDataBase.Instance.rememberMeBehave == RememberMeBehave.RememberSession) { if (SignIn != null && SignIn.RememberMe()) { string p = credentials.authenticationType == AuthenticationType.ULogin ? credentials.UniqueID : credentials.GetUniquePassword(); //if it's so, encrypt and save the authentication credentials that the user used. bl_LoginProDataBase.Instance.RememberCredentials = $"{(int)credentials.authenticationType}:{credentials.UserName}:{p}"; } } if (bl_LoginProDataBase.Instance.AutomaticallyLoadScene)//load the scene after login success (without continue menu) { Continue(); } else { LoginSuccessText.text = string.Format("Welcome <b>{0}</b>", info.NickName); if (info.UserStatus == LoginUserInfo.Status.Admin || info.UserStatus == LoginUserInfo.Status.Moderator) { AdminPanelButon.SetActive(true); } ChangePanel(3); } }
/// <summary> /// /// </summary> /// <returns></returns> IEnumerator LoginProcess(string user, string pass) { isRequesting = true; LoadingUI.SetActive(true); SetLogText(""); //sets the mySQL query to the amount of rows to load Dictionary <string, string> formData = new Dictionary <string, string>(); formData.Add("name", user); formData.Add("password", pass); //Creates instance to run the php script to access the mySQL database using (UnityWebRequest www = UnityWebRequest.Post(bl_LoginProDataBase.Instance.GetUrl(bl_LoginProDataBase.URLType.Login), formData)) { //Wait for server response... yield return(www.SendWebRequest()); string result = www.downloadHandler.text; //check if we have some error if (www.isNetworkError == false && !www.isHttpError) { //decompile information string[] data = result.Split("|"[0]); if (data[0].Contains("success")) { //'Decompile' information from response LoginUserInfo info = new LoginUserInfo(); info.LoginName = data[1]; info.NickName = data[2]; info.Kills = int.Parse(data[3]); info.Deaths = int.Parse(data[4]); info.Score = int.Parse(data[5]); info.PlayTime = int.Parse(data[6]); int st = int.Parse(data[7]); info.UserStatus = (LoginUserInfo.Status)st; info.ID = int.Parse(data[8]);//unique identifier of the player in database info.SetFriends(data[9]); info.Coins = int.Parse(data[10]); info.SavedIP = data[11]; #if CLANS info.Clan = new bl_ClanInfo(); info.Clan.GetSplitInfo(data); yield return(StartCoroutine(info.Clan.GetClanBasicInfo())); ClanButton.SetActive(true); #endif #if SHOP info.ShopData = new bl_ShopUserData(); info.ShopData.GetInfo(data); #endif info.IP = currentIP; //send information to local database DataBase.OnLogin(info); DataBase.CacheAccessToken = pass; LocalUserInfo = info; SignIn.OnLogin(info); SetLogText("Sign In success!"); //detect if this account is banned before load next level if (bl_LoginProDataBase.Instance.DetectBan && Ban.CheckBanAccount(info.LoginName)) { yield break;//just stop here due this account is banned } //if it's OK, load next level of show continue menu isLogin = true; if (OnLogin != null) { OnLogin.Invoke(); } yield return(new WaitForSeconds(1f)); if (bl_LoginProDataBase.Instance.AutomaticallyLoadScene)//load the scene after login success (without continue menu) { Continue(); } else { LoginSuccessText.text = string.Format("Welcome <b>{0}</b>", info.NickName); if (info.UserStatus == LoginUserInfo.Status.Admin || info.UserStatus == LoginUserInfo.Status.Moderator) { AdminPanelButon.SetActive(true); } ChangePanel(3); } } else//Wait, have a error?, please contact me for help with the result of next debug log. { //Some error with the server setup. Debug.Log(result); ErrorType(result); } } else { Debug.LogError("Error: " + www.error); } } LoadingUI.SetActive(false); isRequesting = false; }