Adjust credential saving

This commit is contained in:
varjolintu 2025-07-19 13:21:22 +03:00
parent db8cd1b1f0
commit 08250feabe
2 changed files with 39 additions and 10 deletions

View file

@ -1,5 +1,5 @@
# This repository does not use prettier for formatting but if you want to use it for testing then you can comment out the following line:
#*
*
# Should never format these files:
*.min.js

View file

@ -93,8 +93,43 @@ protocol.changePublicKeys = async function(tab, enableTimeout = false, connectio
};
protocol.createCredentials = async function(tab, args = []) {
const [ username, password, url, group, groupUuid ] = args;
return protocol.updateCredentials(tab, [ null, username, password, url, group, groupUuid ]);
if (!keepass.isConnected) {
return [];
}
const [ username, password, url ] = args;
const messageData = {
action: kpActions.CREATE_CREDENTIALS,
login: username,
password: password,
submitUrl: url,
url: url,
};
if (page.settings.downloadFaviconAfterSave) {
messageData.downloadFavicon = true;
}
try {
const response = await protocolClient.sendMessage(tab, messageData);
if (response) {
keepass.updateLastUsed(keepass.databaseHash);
if (response?.result === true) {
//return entryId ? AddCredentials.UPDATED : AddCredentials.CREATED;
// TODO: KeePassXC should inform if the credential was updated or created
return AddCredentials.CREATED;
}
return AddCredentials.CANCELED;
} else {
return AddCredentials.ERROR;
}
} catch (err) {
logError(`updateCredentials failed: ${err}`);
return [];
}
};
protocol.createNewGroup = async function(tab, args = []) {
@ -474,11 +509,10 @@ protocol.updateCredentials = async function(tab, args = []) {
return [];
}
const [ entryId, username, password, url, group, groupUuid ] = args;
const [ entryId, username, password, url ] = args;
const messageData = {
action: kpActions.CREATE_CREDENTIALS,
keys: protocol.getCurrentKey(),
login: username,
password: password,
submitUrl: url,
@ -493,11 +527,6 @@ protocol.updateCredentials = async function(tab, args = []) {
messageData.downloadFavicon = true;
}
if (group && groupUuid) {
messageData.group = group;
messageData.groupUuid = groupUuid;
}
try {
const response = await protocolClient.sendMessage(tab, messageData);
if (response) {