diff --git a/src/Config.cpp b/src/Config.cpp index ed43295ce..55e5c761c 100644 --- a/src/Config.cpp +++ b/src/Config.cpp @@ -69,16 +69,16 @@ void Config::Load(json config) if (config.contains(PARAM_AUTHREQUIRED) && config[PARAM_AUTHREQUIRED].is_boolean()) AuthRequired = config[PARAM_AUTHREQUIRED]; if (config.contains(PARAM_PASSWORD) && config[PARAM_PASSWORD].is_string()) - ServerPassword = QString::fromStdString(config[PARAM_PASSWORD].get()); + ServerPassword = config[PARAM_PASSWORD]; // Set server password and save it to the config before processing overrides, // so that there is always a true configured password regardless of if // future loads use the override flag. if (FirstLoad) { FirstLoad = false; - if (ServerPassword.isEmpty()) { + if (ServerPassword.empty()) { blog(LOG_INFO, "[Config::Load] (FirstLoad) Generating new server password."); - ServerPassword = QString::fromStdString(Utils::Crypto::GeneratePassword()); + ServerPassword = Utils::Crypto::GeneratePassword(); } else { blog(LOG_INFO, "[Config::Load] (FirstLoad) Not generating new password since one is already configured."); } @@ -111,7 +111,7 @@ void Config::Load(json config) blog(LOG_INFO, "[Config::Load] --websocket_password passed. Overriding WebSocket password."); PasswordOverridden = true; AuthRequired = true; - ServerPassword = passwordArgument; + ServerPassword = passwordArgument.toStdString(); } // Process `--websocket_debug` override @@ -136,7 +136,7 @@ void Config::Save() config[PARAM_ALERTS] = AlertsEnabled.load(); if (!PasswordOverridden) { config[PARAM_AUTHREQUIRED] = AuthRequired.load(); - config[PARAM_PASSWORD] = ServerPassword.toStdString(); + config[PARAM_PASSWORD] = ServerPassword; } if (!Utils::Json::SetJsonFileContent(configFilePath, config)) diff --git a/src/Config.h b/src/Config.h index 706a31f68..f0b52bd7c 100644 --- a/src/Config.h +++ b/src/Config.h @@ -40,7 +40,7 @@ struct Config { std::atomic DebugEnabled = false; std::atomic AlertsEnabled = false; std::atomic AuthRequired = true; - QString ServerPassword; + std::string ServerPassword; }; json MigrateGlobalConfigData(); diff --git a/src/forms/ConnectInfo.cpp b/src/forms/ConnectInfo.cpp index 02442f004..06507a6f9 100644 --- a/src/forms/ConnectInfo.cpp +++ b/src/forms/ConnectInfo.cpp @@ -64,7 +64,7 @@ void ConnectInfo::RefreshData() QString serverPassword; if (conf->AuthRequired) { ui->copyServerPasswordButton->setEnabled(true); - serverPassword = QUrl::toPercentEncoding(conf->ServerPassword); + serverPassword = QUrl::toPercentEncoding(QString::fromStdString(conf->ServerPassword)); } else { ui->copyServerPasswordButton->setEnabled(false); serverPassword = obs_module_text("OBSWebSocket.ConnectInfo.ServerPasswordPlaceholderText"); diff --git a/src/forms/SettingsDialog.cpp b/src/forms/SettingsDialog.cpp index 7fd6d9735..5e8ff8f9d 100644 --- a/src/forms/SettingsDialog.cpp +++ b/src/forms/SettingsDialog.cpp @@ -123,7 +123,7 @@ void SettingsDialog::RefreshData() ui->enableDebugLoggingCheckBox->setChecked(conf->DebugEnabled); ui->serverPortSpinBox->setValue(conf->ServerPort); ui->enableAuthenticationCheckBox->setChecked(conf->AuthRequired); - ui->serverPasswordLineEdit->setText(conf->ServerPassword); + ui->serverPasswordLineEdit->setText(QString::fromStdString(conf->ServerPassword)); ui->serverPasswordLineEdit->setEnabled(conf->AuthRequired); ui->generatePasswordButton->setEnabled(conf->AuthRequired); @@ -158,7 +158,7 @@ void SettingsDialog::SaveFormData() } // Show a confirmation box to the user if they attempt to provide their own password - if (passwordManuallyEdited && (conf->ServerPassword != ui->serverPasswordLineEdit->text())) { + if (passwordManuallyEdited && (conf->ServerPassword != ui->serverPasswordLineEdit->text().toStdString())) { QMessageBox msgBox; msgBox.setWindowTitle(obs_module_text("OBSWebSocket.Settings.Save.UserPasswordWarningTitle")); msgBox.setText(obs_module_text("OBSWebSocket.Settings.Save.UserPasswordWarningMessage")); @@ -172,7 +172,7 @@ void SettingsDialog::SaveFormData() break; case QMessageBox::No: default: - ui->serverPasswordLineEdit->setText(conf->ServerPassword); + ui->serverPasswordLineEdit->setText(QString::fromStdString(conf->ServerPassword)); return; } } @@ -180,14 +180,14 @@ void SettingsDialog::SaveFormData() bool needsRestart = (conf->ServerEnabled != ui->enableWebSocketServerCheckBox->isChecked()) || (conf->ServerPort != ui->serverPortSpinBox->value()) || - (ui->enableAuthenticationCheckBox->isChecked() && conf->ServerPassword != ui->serverPasswordLineEdit->text()); + (ui->enableAuthenticationCheckBox->isChecked() && conf->ServerPassword != ui->serverPasswordLineEdit->text().toStdString()); conf->ServerEnabled = ui->enableWebSocketServerCheckBox->isChecked(); conf->AlertsEnabled = ui->enableSystemTrayAlertsCheckBox->isChecked(); conf->DebugEnabled = ui->enableDebugLoggingCheckBox->isChecked(); conf->ServerPort = ui->serverPortSpinBox->value(); conf->AuthRequired = ui->enableAuthenticationCheckBox->isChecked(); - conf->ServerPassword = ui->serverPasswordLineEdit->text(); + conf->ServerPassword = ui->serverPasswordLineEdit->text().toStdString(); conf->Save(); diff --git a/src/websocketserver/WebSocketServer.cpp b/src/websocketserver/WebSocketServer.cpp index fdea4e801..b5340e2c8 100644 --- a/src/websocketserver/WebSocketServer.cpp +++ b/src/websocketserver/WebSocketServer.cpp @@ -97,7 +97,7 @@ void WebSocketServer::Start() } _authenticationSalt = Utils::Crypto::GenerateSalt(); - _authenticationSecret = Utils::Crypto::GenerateSecret(conf->ServerPassword.toStdString(), _authenticationSalt); + _authenticationSecret = Utils::Crypto::GenerateSecret(conf->ServerPassword, _authenticationSalt); // Set log levels if debug is enabled if (IsDebugEnabled()) {