mirror of
https://github.com/keepassxreboot/keepassxc-browser.git
synced 2026-03-11 08:54:43 +00:00
Adjust credential saving
This commit is contained in:
parent
db8cd1b1f0
commit
08250feabe
2 changed files with 39 additions and 10 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue