mirror of
https://github.com/bitwarden/browser.git
synced 2025-01-03 18:28:13 +01:00
Wait for user to log in before trying to save credentials
This commit is contained in:
parent
5c175e2201
commit
838bfe9454
@ -127,6 +127,7 @@ export default class MainBackground {
|
|||||||
onReplacedRan: boolean;
|
onReplacedRan: boolean;
|
||||||
loginToAutoFill: any = null;
|
loginToAutoFill: any = null;
|
||||||
notificationQueue: any[] = [];
|
notificationQueue: any[] = [];
|
||||||
|
retryQueue: any[] = [];
|
||||||
|
|
||||||
private commandsBackground: CommandsBackground;
|
private commandsBackground: CommandsBackground;
|
||||||
private contextMenusBackground: ContextMenusBackground;
|
private contextMenusBackground: ContextMenusBackground;
|
||||||
|
@ -71,6 +71,18 @@ export default class RuntimeBackground {
|
|||||||
await this.main.refreshBadgeAndMenu(false);
|
await this.main.refreshBadgeAndMenu(false);
|
||||||
this.notificationsService.updateConnection(msg.command === 'unlocked');
|
this.notificationsService.updateConnection(msg.command === 'unlocked');
|
||||||
this.systemService.cancelProcessReload();
|
this.systemService.cancelProcessReload();
|
||||||
|
|
||||||
|
if (this.main.retryQueue.length > 0) {
|
||||||
|
const retryItem = this.main.retryQueue.pop();
|
||||||
|
await this.processMessage(retryItem.msg, retryItem.sender, null);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'addToRetryQueue':
|
||||||
|
const retryMessage = {
|
||||||
|
msg: msg.retryItem,
|
||||||
|
sender: sender,
|
||||||
|
};
|
||||||
|
this.main.retryQueue.push(retryMessage);
|
||||||
break;
|
break;
|
||||||
case 'logout':
|
case 'logout':
|
||||||
await this.main.logout(msg.expired);
|
await this.main.logout(msg.expired);
|
||||||
@ -224,10 +236,6 @@ export default class RuntimeBackground {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async saveAddLogin(tab: any, folderId: string) {
|
private async saveAddLogin(tab: any, folderId: string) {
|
||||||
console.log('saveAddLogin triggered');
|
|
||||||
if (await this.vaultTimeoutService.isLocked()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (let i = this.main.notificationQueue.length - 1; i >= 0; i--) {
|
for (let i = this.main.notificationQueue.length - 1; i >= 0; i--) {
|
||||||
const queueMessage = this.main.notificationQueue[i];
|
const queueMessage = this.main.notificationQueue[i];
|
||||||
@ -268,10 +276,6 @@ export default class RuntimeBackground {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async saveChangePassword(tab: any) {
|
private async saveChangePassword(tab: any) {
|
||||||
console.log('saveChangePassword triggered');
|
|
||||||
if (await this.vaultTimeoutService.isLocked()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (let i = this.main.notificationQueue.length - 1; i >= 0; i--) {
|
for (let i = this.main.notificationQueue.length - 1; i >= 0; i--) {
|
||||||
const queueMessage = this.main.notificationQueue[i];
|
const queueMessage = this.main.notificationQueue[i];
|
||||||
@ -361,20 +365,20 @@ export default class RuntimeBackground {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async pushAddLoginToQueue(loginDomain: string, loginInfo: any, tab: any, isVaultLocked: boolean = false) {
|
private async pushAddLoginToQueue(loginDomain: string, loginInfo: any, tab: any, isVaultLocked: boolean = false) {
|
||||||
// remove any old messages for this tab
|
// remove any old messages for this tab
|
||||||
this.removeTabFromNotificationQueue(tab);
|
this.removeTabFromNotificationQueue(tab);
|
||||||
const message: addLoginQueueMessage = {
|
const message: addLoginQueueMessage = {
|
||||||
type: 'addLogin',
|
type: 'addLogin',
|
||||||
username: loginInfo.username,
|
username: loginInfo.username,
|
||||||
password: loginInfo.password,
|
password: loginInfo.password,
|
||||||
domain: loginDomain,
|
domain: loginDomain,
|
||||||
uri: loginInfo.url,
|
uri: loginInfo.url,
|
||||||
tabId: tab.id,
|
tabId: tab.id,
|
||||||
expires: new Date((new Date()).getTime() + 30 * 60000), // 30 minutes
|
expires: new Date((new Date()).getTime() + 30 * 60000), // 30 minutes
|
||||||
wasVaultLocked: isVaultLocked,
|
wasVaultLocked: isVaultLocked,
|
||||||
};
|
};
|
||||||
this.main.notificationQueue.push(message);
|
this.main.notificationQueue.push(message);
|
||||||
await this.main.checkNotificationQueue(tab);
|
await this.main.checkNotificationQueue(tab);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async changedPassword(changeData: any, tab: any) {
|
private async changedPassword(changeData: any, tab: any) {
|
||||||
|
@ -73,6 +73,12 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
sendPlatformMessage({
|
sendPlatformMessage({
|
||||||
command: 'openPopout'
|
command: 'openPopout'
|
||||||
});
|
});
|
||||||
|
|
||||||
|
sendPlatformMessage({
|
||||||
|
command: 'addToRetryQueue',
|
||||||
|
retryItem: bgAddSaveMessage
|
||||||
|
});
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
sendPlatformMessage(bgAddSaveMessage);
|
sendPlatformMessage(bgAddSaveMessage);
|
||||||
@ -111,6 +117,12 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
sendPlatformMessage({
|
sendPlatformMessage({
|
||||||
command: 'openPopout'
|
command: 'openPopout'
|
||||||
});
|
});
|
||||||
|
|
||||||
|
sendPlatformMessage({
|
||||||
|
command: 'addToRetryQueue',
|
||||||
|
retryItem: bgChangeSaveMessage,
|
||||||
|
});
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
sendPlatformMessage(bgChangeSaveMessage);
|
sendPlatformMessage(bgChangeSaveMessage);
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user