Merge pull request #1731 from keepassxreboot/fix/clf_string_fields

Fix saving Custom Login Fields
This commit is contained in:
Sami Vänttinen 2022-09-24 16:20:52 +03:00 committed by GitHub
commit a13a34ee78
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -323,39 +323,41 @@ kpxcCustomLoginFieldsBanner.confirm = async function() {
const location = kpxc.getDocumentLocation();
const currentSettings = kpxc.settings[DEFINED_CUSTOM_FIELDS][location];
if (currentSettings) {
// Update the single selection to current settings
if (usernamePath) {
clearIdenticalField(usernamePath, location);
kpxc.settings[DEFINED_CUSTOM_FIELDS][location].username = usernamePath;
if (usernamePath || passwordPath || totpPath || stringFieldsPaths.length > 0) {
if (currentSettings) {
// Update the single selection to current settings
if (usernamePath) {
clearIdenticalField(usernamePath, location);
kpxc.settings[DEFINED_CUSTOM_FIELDS][location].username = usernamePath;
}
if (passwordPath) {
clearIdenticalField(passwordPath, location);
kpxc.settings[DEFINED_CUSTOM_FIELDS][location].password = passwordPath;
}
if (totpPath) {
clearIdenticalField(totpPath, location);
kpxc.settings[DEFINED_CUSTOM_FIELDS][location].totp = totpPath;
}
if (stringFieldsPaths.length > 0) {
kpxc.settings[DEFINED_CUSTOM_FIELDS][location].fields = stringFieldsPaths;
}
} else {
// Override all fields (default, because there's no currentSettings available)
kpxc.settings[DEFINED_CUSTOM_FIELDS][location] = {
username: usernamePath,
password: passwordPath,
totp: totpPath,
fields: stringFieldsPaths
};
}
if (passwordPath) {
clearIdenticalField(passwordPath, location);
kpxc.settings[DEFINED_CUSTOM_FIELDS][location].password = passwordPath;
}
if (totpPath) {
clearIdenticalField(totpPath, location);
kpxc.settings[DEFINED_CUSTOM_FIELDS][location].totp = totpPath;
}
if (stringFieldsPaths.length > 0) {
kpxc.settings[DEFINED_CUSTOM_FIELDS][location].fields = stringFieldsPaths;
}
} else {
// Override all fields (default)
kpxc.settings[DEFINED_CUSTOM_FIELDS][location] = {
username: usernamePath,
password: passwordPath,
totp: totpPath,
fields: stringFieldsPaths
};
await sendMessage('save_settings', kpxc.settings);
}
await sendMessage('save_settings', kpxc.settings);
kpxcCustomLoginFieldsBanner.destroy();
sendMessageToFrames('confirm_button_clicked');
};
@ -511,7 +513,6 @@ kpxcCustomLoginFieldsBanner.selectStringFields = function() {
};
kpxcCustomLoginFieldsBanner.markFields = function() {
let index = 1;
let firstInput;
const inputs = document.querySelectorAll(kpxcCustomLoginFieldsBanner.inputQueryPattern);
@ -567,7 +568,6 @@ kpxcCustomLoginFieldsBanner.markFields = function() {
kpxcCustomLoginFieldsBanner.chooser.append(field);
firstInput = field;
++index;
}
}