UI: Load password from registry when "Check Password on Uninstalll" enabled

This commit is contained in:
Nodir Temirkhodjaev 2023-03-24 13:05:18 +03:00
parent 38bab5969d
commit 8cc04a5f22
4 changed files with 29 additions and 3 deletions

View File

@ -328,6 +328,19 @@ void FortSettings::readConfIni(FirewallConf &conf) const
conf.setActivePeriodFrom(DateUtil::reformatTime(iniText("activePeriodFrom")));
conf.setActivePeriodTo(DateUtil::reformatTime(iniText("activePeriodTo")));
ini()->endGroup();
// Ini Options
{
const IniOptions &ini = conf.ini();
// Password
if (ini.checkPasswordOnUninstall()) {
const QString regPasswordHash = StartupUtil::registryPasswordHash();
if (!regPasswordHash.isEmpty()) {
setCacheValue(passwordHashKey(), regPasswordHash);
}
}
}
}
void FortSettings::writeConfIni(const FirewallConf &conf)
@ -362,6 +375,7 @@ void FortSettings::writeConfIni(const FirewallConf &conf)
changed = true;
}
// Ini Options
if (conf.iniEdited()) {
const IniOptions &ini = conf.ini();

View File

@ -13,8 +13,10 @@ class FortSettings : public Settings
public:
explicit FortSettings(QObject *parent = nullptr);
QString passwordHash() const { return iniText("base/passwordHash"); }
void setPasswordHash(const QString &v) { setIniValue("base/passwordHash", v); }
static QString passwordHashKey() { return "base/passwordHash"; }
QString passwordHash() const { return iniText(passwordHashKey()); }
void setPasswordHash(const QString &v) { setIniValue(passwordHashKey(), v); }
bool isDefaultProfilePath() const { return m_isDefaultProfilePath; }
bool noCache() const { return m_noCache; }

View File

@ -282,11 +282,20 @@ void StartupUtil::setExplorerIntegrated(bool integrate)
}
}
QString StartupUtil::registryPasswordHash()
{
const RegKey regApp(RegKey::HKLM, R"(SOFTWARE)");
const RegKey reg(regApp, APP_NAME);
return reg.value("passwordHash").toString();
}
void StartupUtil::setRegistryPasswordHash(const QString &passwordHash)
{
const bool isAdding = !passwordHash.isEmpty();
RegKey regApp(RegKey::HKLM, R"(SOFTWARE)",
const RegKey regApp(RegKey::HKLM, R"(SOFTWARE)",
isAdding ? RegKey::DefaultCreate : RegKey::DefaultReadWrite);
RegKey reg(regApp, APP_NAME, RegKey::DefaultCreate);

View File

@ -21,6 +21,7 @@ public:
static bool isExplorerIntegrated();
static void setExplorerIntegrated(bool integrate);
static QString registryPasswordHash();
static void setRegistryPasswordHash(const QString &passwordHash);
static void setPortable(bool portable);