mirror of
https://github.com/bitwarden/browser.git
synced 2024-10-02 04:48:57 +02:00
detect password change on login
This commit is contained in:
parent
6ddfd98fc4
commit
539ee0b1b6
2
jslib
2
jslib
@ -1 +1 @@
|
||||
Subproject commit 49d3f227042bc090dec48f83bbbf7da3029828a5
|
||||
Subproject commit 3429b57db42a3e1e9948b870bf24fcc02ebc8a99
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user