mirror of
https://github.com/keepassxreboot/keepassxc-browser.git
synced 2026-03-11 08:54:43 +00:00
Automatically reconnect on keyboard shortcuts (#1728)
Automatically reconnect to database on keyboard shortcut
This commit is contained in:
parent
a93ac4b3ac
commit
ab07314a5b
2 changed files with 23 additions and 12 deletions
|
|
@ -833,16 +833,20 @@ browser.runtime.onMessage.addListener(async function(req, sender) {
|
|||
} else if (req.action === 'clear_credentials') {
|
||||
kpxc.clearAllFromPage();
|
||||
} else if (req.action === 'fill_user_pass_with_specific_login') {
|
||||
await kpxc.reconnect();
|
||||
kpxcFill.fillFromPopup(req.id, req.uuid);
|
||||
} else if (req.action === 'fill_username_password') {
|
||||
await kpxc.reconnect();
|
||||
sendMessage('page_set_manual_fill', ManualFill.BOTH);
|
||||
await kpxc.receiveCredentialsIfNecessary();
|
||||
kpxcFill.fillInFromActiveElement();
|
||||
} else if (req.action === 'fill_password') {
|
||||
await kpxc.reconnect();
|
||||
sendMessage('page_set_manual_fill', ManualFill.PASSWORD);
|
||||
await kpxc.receiveCredentialsIfNecessary();
|
||||
kpxcFill.fillInFromActiveElement(true); // passOnly to true
|
||||
} else if (req.action === 'fill_totp') {
|
||||
await kpxc.reconnect();
|
||||
await kpxc.receiveCredentialsIfNecessary();
|
||||
kpxcFill.fillFromTOTP();
|
||||
} else if (req.action === 'fill_attribute' && req.args) {
|
||||
|
|
@ -869,3 +873,18 @@ browser.runtime.onMessage.addListener(async function(req, sender) {
|
|||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Automatically reconnect to KeePassXC
|
||||
// returns true if connected afterwards
|
||||
kpxc.reconnect = async function() {
|
||||
// Try to reconnect if KeePassXC is not currently connected
|
||||
const connected = await sendMessage('is_connected');
|
||||
if (!connected) {
|
||||
const reconnectResponse = await sendMessage('reconnect');
|
||||
if (!reconnectResponse.keePassXCAvailable) {
|
||||
kpxcUI.createNotification('error', tr('errorNotConnected'));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -123,18 +123,10 @@ const iconClicked = async function(field, icon) {
|
|||
return;
|
||||
}
|
||||
|
||||
let reconnected = false;
|
||||
|
||||
// Try to reconnect if KeePassXC is not currently connected
|
||||
const connected = await sendMessage('is_connected');
|
||||
// Try to reconnect if KeePassXC for the case we're not currently connected
|
||||
const connected = await kpxc.reconnect();
|
||||
if (!connected) {
|
||||
const reconnectResponse = await sendMessage('reconnect');
|
||||
if (!reconnectResponse.keePassXCAvailable) {
|
||||
kpxcUI.createNotification('error', tr('errorNotConnected'));
|
||||
return;
|
||||
}
|
||||
|
||||
reconnected = true;
|
||||
return;
|
||||
}
|
||||
|
||||
const databaseHash = await sendMessage('check_database_hash');
|
||||
|
|
@ -145,7 +137,7 @@ const iconClicked = async function(field, icon) {
|
|||
field.focus();
|
||||
}
|
||||
|
||||
if (icon.className.includes('unlock') || reconnected) {
|
||||
if (icon.className.includes('unlock')) {
|
||||
fillCredentials(field);
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue