detech password changes with 2 equal passwords

This commit is contained in:
Kyle Spearrin 2018-09-07 08:01:50 -04:00
parent 768aab2bf8
commit d2e5c9b6ea
2 changed files with 25 additions and 10 deletions

View File

@ -316,10 +316,18 @@ export default class RuntimeBackground {
return; return;
} }
let id: string = null;
const ciphers = await this.cipherService.getAllDecryptedForUrl(changeData.url); const ciphers = await this.cipherService.getAllDecryptedForUrl(changeData.url);
const passwordMatches = ciphers.filter((c) => c.login.password === changeData.currentPassword); if (changeData.currentPassword != null) {
if (passwordMatches.length === 1) { const passwordMatches = ciphers.filter((c) => c.login.password === changeData.currentPassword);
this.addChangedPasswordToQueue(passwordMatches[0].id, loginDomain, changeData.newPassword, tab); 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);
} }
} }

View File

@ -351,6 +351,7 @@ document.addEventListener('DOMContentLoaded', (event) => {
let curPass: string = null; let curPass: string = null;
let newPass: string = null; let newPass: string = null;
let newPassOnly = false;
if (formData[i].passwordEls.length === 3 && passwords.length === 3) { if (formData[i].passwordEls.length === 3 && passwords.length === 3) {
newPass = passwords[1]; newPass = passwords[1];
if (passwords[0] !== newPass && newPass === passwords[2]) { if (passwords[0] !== newPass && newPass === passwords[2]) {
@ -359,16 +360,22 @@ document.addEventListener('DOMContentLoaded', (event) => {
curPass = passwords[2]; curPass = passwords[2];
} }
} else if (formData[i].passwordEls.length === 2 && passwords.length === 2) { } else if (formData[i].passwordEls.length === 2 && passwords.length === 2) {
const buttonText = getButtonText(getSubmitButton(form, changePasswordButtonNames)); if (passwords[0] === passwords[1]) {
const matches = Array.from(changePasswordButtonContainsNames) newPassOnly = true;
.filter((n) => buttonText.indexOf(n) > -1); newPass = passwords[0];
if (matches.length > 0) { curPass = null;
curPass = passwords[0]; } else {
newPass = passwords[1]; 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); processedForm(form);
sendPlatformMessage({ sendPlatformMessage({
command: 'bgChangedPassword', command: 'bgChangedPassword',