From 9301c3b915a84839cc60ca96a092b6b2593f67bc Mon Sep 17 00:00:00 2001 From: varjolintu Date: Sat, 29 Dec 2018 11:15:44 +0200 Subject: [PATCH] Clear credentials when the screen is locked --- keepassxc-browser/keepassxc-browser.js | 31 ++++++++++++++------------ 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/keepassxc-browser/keepassxc-browser.js b/keepassxc-browser/keepassxc-browser.js index 93160dd..5a8e50b 100755 --- a/keepassxc-browser/keepassxc-browser.js +++ b/keepassxc-browser/keepassxc-browser.js @@ -1401,22 +1401,26 @@ cip.init = function() { }); }; +// Clears all from the content and background scripts, including autocomplete +cip.clearAllFromPage = function() { + cipEvents.clearCredentials(); + + browser.runtime.sendMessage({ + action: 'page_clear_logins' + }); + + // Switch back to default popup + browser.runtime.sendMessage({ + action: 'get_status', + args: [ true ] // Set polling to true, this is an internal function call + }); +}; + // Switch credentials if database is changed or closed cip.detectDatabaseChange = function(response) { + cip.clearAllFromPage(); if (document.visibilityState !== 'hidden') { - if (response.new === '' && response.old !== '') { - cipEvents.clearCredentials(); - - browser.runtime.sendMessage({ - action: 'page_clear_logins' - }); - - // Switch back to default popup - browser.runtime.sendMessage({ - action: 'get_status', - args: [ true ] // Set polling to true, this is an internal function call - }); - } else if (response.new !== '' && response.new !== response.old) { + if (response.new !== '' && response.new !== response.old) { _called.retrieveCredentials = false; browser.runtime.sendMessage({ action: 'load_settings', @@ -1488,7 +1492,6 @@ cip.initCredentialFields = function(forceCall) { } if (cip.settings.autoRetrieveCredentials && _called.retrieveCredentials === false && (cip.url && cip.submitUrl)) { - _called.retrieveCredentials = true; browser.runtime.sendMessage({ action: 'retrieve_credentials', args: [ cip.url, cip.submitUrl ]