mirror of
https://github.com/bitwarden/browser
synced 2025-12-13 14:53:33 +00:00
reseed storage on logout
This commit is contained in:
2
jslib
2
jslib
Submodule jslib updated: 53260a5be8...f67fac3eeb
@@ -280,6 +280,7 @@ export default class MainBackground {
|
|||||||
|
|
||||||
await this.setIcon();
|
await this.setIcon();
|
||||||
await this.refreshBadgeAndMenu();
|
await this.refreshBadgeAndMenu();
|
||||||
|
await this.reseedStorage();
|
||||||
this.notificationsService.updateConnection(false);
|
this.notificationsService.updateConnection(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -339,6 +340,36 @@ export default class MainBackground {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async reseedStorage() {
|
||||||
|
if (!this.platformUtilsService.isChrome() && !this.platformUtilsService.isVivaldi() &&
|
||||||
|
!this.platformUtilsService.isOpera()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const currentLockOption = await this.storageService.get<number>(ConstantsService.lockOptionKey);
|
||||||
|
if (currentLockOption == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const getStorage = (): Promise<any> => new Promise((resolve) => {
|
||||||
|
chrome.storage.local.get(null, (o: any) => resolve(o));
|
||||||
|
});
|
||||||
|
|
||||||
|
const clearStorage = (): Promise<void> => new Promise((resolve) => {
|
||||||
|
chrome.storage.local.clear(() => resolve());
|
||||||
|
});
|
||||||
|
|
||||||
|
const storage = await getStorage();
|
||||||
|
await clearStorage();
|
||||||
|
|
||||||
|
for (const key in storage) {
|
||||||
|
if (!storage.hasOwnProperty(key)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
await this.storageService.save(key, storage[key]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private async buildContextMenu() {
|
private async buildContextMenu() {
|
||||||
if (this.isSafari || !chrome.contextMenus || this.buildingContextMenu) {
|
if (this.isSafari || !chrome.contextMenus || this.buildingContextMenu) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -140,7 +140,7 @@ export default class RuntimeBackground {
|
|||||||
await this.main.refreshBadgeAndMenu();
|
await this.main.refreshBadgeAndMenu();
|
||||||
break;
|
break;
|
||||||
case 'bgReseedStorage':
|
case 'bgReseedStorage':
|
||||||
await this.reseedStorage();
|
await this.main.reseedStorage();
|
||||||
break;
|
break;
|
||||||
case 'collectPageDetailsResponse':
|
case 'collectPageDetailsResponse':
|
||||||
switch (msg.sender) {
|
switch (msg.sender) {
|
||||||
@@ -390,36 +390,6 @@ export default class RuntimeBackground {
|
|||||||
}, 100);
|
}, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async reseedStorage() {
|
|
||||||
if (!this.platformUtilsService.isChrome() && !this.platformUtilsService.isVivaldi() &&
|
|
||||||
!this.platformUtilsService.isOpera()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const currentLockOption = await this.storageService.get<number>(ConstantsService.lockOptionKey);
|
|
||||||
if (currentLockOption == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const getStorage = (): Promise<any> => new Promise((resolve) => {
|
|
||||||
chrome.storage.local.get(null, (o: any) => resolve(o));
|
|
||||||
});
|
|
||||||
|
|
||||||
const clearStorage = (): Promise<void> => new Promise((resolve) => {
|
|
||||||
chrome.storage.local.clear(() => resolve());
|
|
||||||
});
|
|
||||||
|
|
||||||
const storage = await getStorage();
|
|
||||||
await clearStorage();
|
|
||||||
|
|
||||||
for (const key in storage) {
|
|
||||||
if (!storage.hasOwnProperty(key)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
await this.storageService.save(key, storage[key]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async setDefaultSettings() {
|
private async setDefaultSettings() {
|
||||||
// Default lock options to "on restart".
|
// Default lock options to "on restart".
|
||||||
const currentLockOption = await this.storageService.get<number>(ConstantsService.lockOptionKey);
|
const currentLockOption = await this.storageService.get<number>(ConstantsService.lockOptionKey);
|
||||||
|
|||||||
Reference in New Issue
Block a user