detect password change on login

This commit is contained in:
Kyle Spearrin 2018-08-06 13:37:29 -04:00
parent 6ddfd98fc4
commit 539ee0b1b6
2 changed files with 22 additions and 23 deletions

2
jslib

@ -1 +1 @@
Subproject commit 49d3f227042bc090dec48f83bbbf7da3029828a5
Subproject commit 3429b57db42a3e1e9948b870bf24fcc02ebc8a99

View File

@ -278,15 +278,8 @@ export default class RuntimeBackground {
}
const ciphers = await this.cipherService.getAllDecryptedForUrl(loginInfo.url);
let match = false;
for (let i = 0; i < ciphers.length; i++) {
if (ciphers[i].login.username === loginInfo.username) {
match = true;
break;
}
}
if (!match) {
const usernameMatches = ciphers.filter((c) => c.login.username === loginInfo.username);
if (usernameMatches.length === 0) {
// remove any old messages for this tab
this.removeTabFromNotificationQueue(tab);
this.main.notificationQueue.push({
@ -299,6 +292,8 @@ export default class RuntimeBackground {
expires: new Date((new Date()).getTime() + 30 * 60000), // 30 minutes
});
await this.main.checkNotificationQueue(tab);
} else if (usernameMatches.length === 1 && usernameMatches[0].login.password !== loginInfo.password) {
this.addChangedPasswordToQueue(usernameMatches[0].id, loginDomain, loginInfo.password, tab);
}
}
@ -309,22 +304,26 @@ export default class RuntimeBackground {
}
const ciphers = await this.cipherService.getAllDecryptedForUrl(changeData.url);
const matches = ciphers.filter((c) => c.login.password === changeData.currentPassword);
if (matches.length === 1) {
// remove any old messages for this tab
this.removeTabFromNotificationQueue(tab);
this.main.notificationQueue.push({
type: 'changePassword',
cipherId: matches[0].id,
newPassword: changeData.newPassword,
domain: loginDomain,
tabId: tab.id,
expires: new Date((new Date()).getTime() + 30 * 60000), // 30 minutes
});
await this.main.checkNotificationQueue(tab);
const passwordMatches = ciphers.filter((c) => c.login.password === changeData.currentPassword);
if (passwordMatches.length === 1) {
this.addChangedPasswordToQueue(passwordMatches[0].id, loginDomain, changeData.newPassword, tab);
}
}
private async addChangedPasswordToQueue(cipherId: string, loginDomain: string, newPassword: string, tab: any) {
// remove any old messages for this tab
this.removeTabFromNotificationQueue(tab);
this.main.notificationQueue.push({
type: 'changePassword',
cipherId: cipherId,
newPassword: newPassword,
domain: loginDomain,
tabId: tab.id,
expires: new Date((new Date()).getTime() + 30 * 60000), // 30 minutes
});
await this.main.checkNotificationQueue(tab);
}
private removeTabFromNotificationQueue(tab: any) {
for (let i = this.main.notificationQueue.length - 1; i >= 0; i--) {
if (this.main.notificationQueue[i].tabId === tab.id) {