private void SaveConfig() { Settings s = instance.GlobalSettings; SavedLogin sl = new SavedLogin(); string username = cbxUsername.Text; if (cbxUsername.SelectedIndex > 0 && cbxUsername.SelectedItem is SavedLogin) { username = ((SavedLogin)cbxUsername.SelectedItem).Username; } if (cbxGrid.SelectedIndex == cbxGrid.Items.Count - 1) // custom login uri { sl.GridID = "custom_login_uri"; sl.CustomURI = txtCustomLoginUri.Text; } else { sl.GridID = (cbxGrid.SelectedItem as Grid).ID; sl.CustomURI = string.Empty; } string savedLoginsKey = string.Format("{0}%{1}", username, sl.GridID); if (!(s["saved_logins"] is OSDMap)) { s["saved_logins"] = new OSDMap(); } if (cbRemember.Checked) { sl.Username = s["username"] = username; if (LoginOptions.IsPasswordMD5(txtPassword.Text)) { sl.Password = txtPassword.Text; s["password"] = txtPassword.Text; } else { sl.Password = Utils.MD5(txtPassword.Text); s["password"] = Utils.MD5(txtPassword.Text); } if (cbxLocation.SelectedIndex == -1) { sl.CustomStartLocation = cbxLocation.Text; } else { sl.CustomStartLocation = string.Empty; } sl.StartLocationType = cbxLocation.SelectedIndex; ((OSDMap)s["saved_logins"])[savedLoginsKey] = sl.ToOSD(); } else if (((OSDMap)s["saved_logins"]).ContainsKey(savedLoginsKey)) { ((OSDMap)s["saved_logins"]).Remove(savedLoginsKey); } s["login_location_type"] = OSD.FromInteger(cbxLocation.SelectedIndex); s["login_location"] = OSD.FromString(cbxLocation.Text); s["login_grid"] = OSD.FromInteger(cbxGrid.SelectedIndex); s["login_uri"] = OSD.FromString(txtCustomLoginUri.Text); s["remember_login"] = cbRemember.Checked; }
private void SaveConfig() { Settings s = instance.GlobalSettings; SavedLogin sl = new SavedLogin(); string username = cbxUsername.Text; if (cbxUsername.SelectedIndex > 0 && cbxUsername.SelectedItem is SavedLogin) { username = ((SavedLogin)cbxUsername.SelectedItem).Username; } if (cbxGrid.SelectedIndex == cbxGrid.Items.Count - 1) // custom login uri { sl.GridID = "custom_login_uri"; sl.CustomURI = txtCustomLoginUri.Text; } else { sl.GridID = (cbxGrid.SelectedItem as Grid).ID; sl.CustomURI = string.Empty; } string savedLoginsKey = string.Format("{0}%{1}", username, sl.GridID); if (!(s["saved_logins"] is OSDMap)) { s["saved_logins"] = new OSDMap(); } if (cbRemember.Checked) { sl.Username = s["username"] = username; if (LoginOptions.IsPasswordMD5(txtPassword.Text)) { sl.Password = txtPassword.Text; s["password"] = txtPassword.Text; } else { sl.Password =Utils.MD5(txtPassword.Text); s["password"] = Utils.MD5(txtPassword.Text); } if (cbxLocation.SelectedIndex == -1) { sl.CustomStartLocation = cbxLocation.Text; } else { sl.CustomStartLocation = string.Empty; } sl.StartLocationType = cbxLocation.SelectedIndex; ((OSDMap)s["saved_logins"])[savedLoginsKey] = sl.ToOSD(); } else if (((OSDMap)s["saved_logins"]).ContainsKey(savedLoginsKey)) { ((OSDMap)s["saved_logins"]).Remove(savedLoginsKey); } s["login_location_type"] = OSD.FromInteger(cbxLocation.SelectedIndex); s["login_location"] = OSD.FromString(cbxLocation.Text); s["login_grid"] = OSD.FromInteger(cbxGrid.SelectedIndex); s["login_uri"] = OSD.FromString(txtCustomLoginUri.Text); s["remember_login"] = cbRemember.Checked; }
private void SaveConfig() { var globalSettings = instance.GlobalSettings; var savedLogin = new SavedLogin(); var username = cbxUsername.Text; var passTxt = txtPassword.Text; if (cbxUsername.SelectedIndex > 0 && cbxUsername.SelectedItem is SavedLogin login) { username = login.Username; } if (cbxGrid.SelectedIndex == cbxGrid.Items.Count - 1) // custom login uri { savedLogin.GridID = "custom_login_uri"; savedLogin.CustomURI = txtCustomLoginUri.Text; } else { savedLogin.GridID = (cbxGrid.SelectedItem as Grid)?.ID; savedLogin.CustomURI = string.Empty; } var savedLoginsKey = $"{username}%{savedLogin.GridID}"; if (!(globalSettings["saved_logins"] is OSDMap)) { globalSettings["saved_logins"] = new OSDMap(); } if (cbRemember.Checked) { savedLogin.Username = globalSettings["username"] = username; if (LoginOptions.IsPasswordMD5(passTxt)) { savedLogin.Password = passTxt; globalSettings["password"] = passTxt; } else { var passwd = Utils.MD5(passTxt.Length > 16 ? passTxt.Substring(0, 16) : passTxt); savedLogin.Password = passwd; globalSettings["password"] = passwd; } savedLogin.CustomStartLocation = cbxLocation.SelectedIndex == -1 ? cbxLocation.Text : string.Empty; savedLogin.StartLocationType = cbxLocation.SelectedIndex; var savedLogins = (OSDMap)globalSettings["saved_logins"]; if (savedLogins.ContainsKey(savedLoginsKey)) { var sl = SavedLogin.FromOSD(savedLogins[savedLoginsKey]); if (!string.IsNullOrWhiteSpace(sl.MfaHash)) { savedLogin.MfaHash = sl.MfaHash; } } ((OSDMap)globalSettings["saved_logins"])[savedLoginsKey] = savedLogin.ToOSD(); } else if (((OSDMap)globalSettings["saved_logins"]).ContainsKey(savedLoginsKey)) { ((OSDMap)globalSettings["saved_logins"]).Remove(savedLoginsKey); } globalSettings["login_location_type"] = OSD.FromInteger(cbxLocation.SelectedIndex); globalSettings["login_location"] = OSD.FromString(cbxLocation.Text); globalSettings["login_grid"] = OSD.FromString(savedLogin.GridID); globalSettings["login_grid_idx"] = OSD.FromInteger(cbxGrid.SelectedIndex); globalSettings["login_uri"] = OSD.FromString(txtCustomLoginUri.Text); globalSettings["remember_login"] = cbRemember.Checked; }