From fcb12ae300fe14af9011dabb0c11c818cf35ba88 Mon Sep 17 00:00:00 2001 From: Rookiestyle Date: Mon, 14 Dec 2020 11:35:24 +0100 Subject: [PATCH] Give TOTP field higher priority than KPH: fields when using action get-totp Fixes #1144 --- keepassxc-browser/content/keepassxc-browser.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/keepassxc-browser/content/keepassxc-browser.js b/keepassxc-browser/content/keepassxc-browser.js index dcf7dba..5e00bad 100755 --- a/keepassxc-browser/content/keepassxc-browser.js +++ b/keepassxc-browser/content/keepassxc-browser.js @@ -817,15 +817,7 @@ kpxc.fillFromTOTP = async function(target) { if (index >= 0 && kpxc.credentials[index]) { // Check the value from StringFields - if (kpxc.credentials[index].stringFields && kpxc.credentials[index].stringFields.length > 0) { - const stringFields = kpxc.credentials[index].stringFields; - for (const s of stringFields) { - const val = s['KPH: {TOTP}']; - if (val) { - kpxc.setValue(el, val); - } - } - } else if (kpxc.credentials[index].totp && kpxc.credentials[index].totp.length > 0) { + if (kpxc.credentials[index].totp && kpxc.credentials[index].totp.length > 0) { // Retrieve a new TOTP value const totp = await sendMessage('get_totp', [ kpxc.credentials[index].uuid, kpxc.credentials[index].totp ]); if (!totp) { @@ -834,6 +826,14 @@ kpxc.fillFromTOTP = async function(target) { } kpxc.setValue(el, totp); + } else if (kpxc.credentials[index].stringFields && kpxc.credentials[index].stringFields.length > 0) { + const stringFields = kpxc.credentials[index].stringFields; + for (const s of stringFields) { + const val = s['KPH: {TOTP}']; + if (val) { + kpxc.setValue(el, val); + } + } } } };