From d2e5c9b6eaf266fbe1c7101e17e570323b08ed28 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Fri, 7 Sep 2018 08:01:50 -0400 Subject: [PATCH] detech password changes with 2 equal passwords --- src/background/runtime.background.ts | 14 +++++++++++--- src/content/notificationBar.ts | 21 ++++++++++++++------- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/src/background/runtime.background.ts b/src/background/runtime.background.ts index cb781c38a1..f3a553a722 100644 --- a/src/background/runtime.background.ts +++ b/src/background/runtime.background.ts @@ -316,10 +316,18 @@ export default class RuntimeBackground { return; } + let id: string = null; const ciphers = await this.cipherService.getAllDecryptedForUrl(changeData.url); - const passwordMatches = ciphers.filter((c) => c.login.password === changeData.currentPassword); - if (passwordMatches.length === 1) { - this.addChangedPasswordToQueue(passwordMatches[0].id, loginDomain, changeData.newPassword, tab); + if (changeData.currentPassword != null) { + const passwordMatches = ciphers.filter((c) => c.login.password === changeData.currentPassword); + if (passwordMatches.length === 1) { + id = passwordMatches[0].id; + } + } else if (ciphers.length === 1) { + id = ciphers[0].id; + } + if (id != null) { + this.addChangedPasswordToQueue(id, loginDomain, changeData.newPassword, tab); } } diff --git a/src/content/notificationBar.ts b/src/content/notificationBar.ts index f94cf7f4a5..0b7aa4c754 100644 --- a/src/content/notificationBar.ts +++ b/src/content/notificationBar.ts @@ -351,6 +351,7 @@ document.addEventListener('DOMContentLoaded', (event) => { let curPass: string = null; let newPass: string = null; + let newPassOnly = false; if (formData[i].passwordEls.length === 3 && passwords.length === 3) { newPass = passwords[1]; if (passwords[0] !== newPass && newPass === passwords[2]) { @@ -359,16 +360,22 @@ document.addEventListener('DOMContentLoaded', (event) => { curPass = passwords[2]; } } else if (formData[i].passwordEls.length === 2 && passwords.length === 2) { - const buttonText = getButtonText(getSubmitButton(form, changePasswordButtonNames)); - const matches = Array.from(changePasswordButtonContainsNames) - .filter((n) => buttonText.indexOf(n) > -1); - if (matches.length > 0) { - curPass = passwords[0]; - newPass = passwords[1]; + if (passwords[0] === passwords[1]) { + newPassOnly = true; + newPass = passwords[0]; + curPass = null; + } else { + const buttonText = getButtonText(getSubmitButton(form, changePasswordButtonNames)); + const matches = Array.from(changePasswordButtonContainsNames) + .filter((n) => buttonText.indexOf(n) > -1); + if (matches.length > 0) { + curPass = passwords[0]; + newPass = passwords[1]; + } } } - if (newPass != null && curPass != null) { + if (newPass != null && curPass != null || (newPassOnly && newPass != null)) { processedForm(form); sendPlatformMessage({ command: 'bgChangedPassword',