Exemple #1
0
 private void ValidateResponse(DevClientPackets type, LoginData data)
 {
     if (InvokeRequired)
     {
         Invoke(new Action<DevClientPackets, LoginData>(ValidateResponse), type, data);
         return;
     }
 }
Exemple #2
0
        private void LoginResponse(DevClientPackets type, LoginData data)
        {
            if (InvokeRequired)
            {
                Invoke(new Action<DevClientPackets, LoginData>(LoginResponse), type, data);
                return;
            }
            else if (type == DevClientPackets.LoginFailed)
            {
                loginBtn.Enabled = true;
                MessageBox.Show(Program.LanguageManager.Translation.LoginFailed);
            }
            else if (type == DevClientPackets.Invalid)
            {
                loginBtn.Enabled = true;
                MessageBox.Show(Program.LanguageManager.Translation.LoginInvalid);
            }
            else
            {
                if (Program.UserInfo == null)
                {
                    Program.UserInfo = new UserData
                        {
                            rank = data.UserRank,
                            username = data.Username,
                            team = data.Team,
                            teamRank = data.TeamRank
                        };
                    Program.LoginKey = data.LoginKey;
                    Program.MainForm.Login();

                    if (savePassCheckBox.Checked)
                    {
                        if (!Program.Config.SavePassword || Program.Config.SavedUsername != usernameInput.Text)
                        {
                            Program.Config.SavePassword = true;
                            Program.Config.SavedUsername = usernameInput.Text;
                            Program.Config.EncodedPassword = LauncherHelper.EncodePassword(passwordInput.Text);
                            Program.SaveConfig(Program.ConfigurationFilename, Program.Config);
                        }
                    }
                    else
                    {
                        if (Program.Config.SavePassword)
                        {
                            Program.Config.SavePassword = false;
                            Program.Config.EncodedPassword = string.Empty;
                            Program.SaveConfig(Program.ConfigurationFilename, Program.Config);
                        }
                    }
                }
            }
        }