mirror of
https://github.com/bitwarden/browser
synced 2025-12-13 23:03:32 +00:00
detect password change on login
This commit is contained in:
2
jslib
2
jslib
Submodule jslib updated: 49d3f22704...3429b57db4
@@ -278,15 +278,8 @@ export default class RuntimeBackground {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const ciphers = await this.cipherService.getAllDecryptedForUrl(loginInfo.url);
|
const ciphers = await this.cipherService.getAllDecryptedForUrl(loginInfo.url);
|
||||||
let match = false;
|
const usernameMatches = ciphers.filter((c) => c.login.username === loginInfo.username);
|
||||||
for (let i = 0; i < ciphers.length; i++) {
|
if (usernameMatches.length === 0) {
|
||||||
if (ciphers[i].login.username === loginInfo.username) {
|
|
||||||
match = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!match) {
|
|
||||||
// remove any old messages for this tab
|
// remove any old messages for this tab
|
||||||
this.removeTabFromNotificationQueue(tab);
|
this.removeTabFromNotificationQueue(tab);
|
||||||
this.main.notificationQueue.push({
|
this.main.notificationQueue.push({
|
||||||
@@ -299,6 +292,8 @@ export default class RuntimeBackground {
|
|||||||
expires: new Date((new Date()).getTime() + 30 * 60000), // 30 minutes
|
expires: new Date((new Date()).getTime() + 30 * 60000), // 30 minutes
|
||||||
});
|
});
|
||||||
await this.main.checkNotificationQueue(tab);
|
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 ciphers = await this.cipherService.getAllDecryptedForUrl(changeData.url);
|
||||||
const matches = ciphers.filter((c) => c.login.password === changeData.currentPassword);
|
const passwordMatches = ciphers.filter((c) => c.login.password === changeData.currentPassword);
|
||||||
if (matches.length === 1) {
|
if (passwordMatches.length === 1) {
|
||||||
// remove any old messages for this tab
|
this.addChangedPasswordToQueue(passwordMatches[0].id, loginDomain, changeData.newPassword, 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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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) {
|
private removeTabFromNotificationQueue(tab: any) {
|
||||||
for (let i = this.main.notificationQueue.length - 1; i >= 0; i--) {
|
for (let i = this.main.notificationQueue.length - 1; i >= 0; i--) {
|
||||||
if (this.main.notificationQueue[i].tabId === tab.id) {
|
if (this.main.notificationQueue[i].tabId === tab.id) {
|
||||||
|
|||||||
Reference in New Issue
Block a user