Apply suggestions from code review

Co-authored-by: Gauthier Dandele <92022724+GogoVega@users.noreply.github.com>
pull/4975/head
Nick O'Leary 2024-12-06 13:45:48 +00:00 committed by GitHub
parent 4e61c54be5
commit 66bd1feb47
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 0 deletions

View File

@ -492,8 +492,14 @@ RED.history = (function() {
});
}
if (i === "credentials" && ev.changes[i]) {
// Reset - Only want to keep the changes
inverseEv.changes[i] = {};
for (const [key, value] of Object.entries(ev.changes[i])) {
inverseEv.changes[i][key] = ev.node.credentials[key];
ev.node.credentials[key] = value;
if (ev.node._def.credentials[key]?.type === 'password') {
ev.node.credentials['has_' + key] = !!value;
}
}
} else {
ev.node[i] = ev.changes[i];

View File

@ -855,6 +855,12 @@ RED.editor = (function() {
for (const prop in editing_node._def.credentials) {
if (Object.prototype.hasOwnProperty.call(editing_node._def.credentials, prop)) {
if (oldCreds[prop] !== editing_node.credentials[prop]) {
if (editing_node.credentials[prop] === '__PWRD__') {
// The password may not exist in oldCreds
// The value '__PWRD__' means the password exists,
// so ignore this change
continue;
}
editState.changes.credentials = editState.changes.credentials || {};
editState.changes.credentials[prop] = oldCreds[prop];
editState.changed = true;