1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-13 23:03:32 +00:00

reseed storage on logout

This commit is contained in:
Kyle Spearrin
2019-02-13 11:34:42 -05:00
parent f4a7e7591d
commit a2064939d2
3 changed files with 33 additions and 32 deletions

View File

@@ -140,7 +140,7 @@ export default class RuntimeBackground {
await this.main.refreshBadgeAndMenu();
break;
case 'bgReseedStorage':
await this.reseedStorage();
await this.main.reseedStorage();
break;
case 'collectPageDetailsResponse':
switch (msg.sender) {
@@ -390,36 +390,6 @@ export default class RuntimeBackground {
}, 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() {
// Default lock options to "on restart".
const currentLockOption = await this.storageService.get<number>(ConstantsService.lockOptionKey);