diff --git a/src/_locales/en/messages.json b/src/_locales/en/messages.json index f6e770e82f7..34929a1c941 100644 --- a/src/_locales/en/messages.json +++ b/src/_locales/en/messages.json @@ -1076,5 +1076,8 @@ "datePasswordUpdated": { "message": "Password Updated", "description": "ex. Date this password was updated" + }, + "neverLockWarning": { + "message": "Are you sure you want to use the \"Never\" option? Setting your lock options to \"Never\" stores your vault's encryption key on your device. If you use this option you should ensure that you keep your device properly protected." } } diff --git a/src/background/runtime.background.ts b/src/background/runtime.background.ts index f3a553a722d..ed3e4351d71 100644 --- a/src/background/runtime.background.ts +++ b/src/background/runtime.background.ts @@ -137,6 +137,9 @@ export default class RuntimeBackground { case 'bgUpdateContextMenu': await this.main.refreshBadgeAndMenu(); break; + case 'bgReseedStorage': + await this.reseedStorage(); + break; case 'collectPageDetailsResponse': switch (msg.sender) { case 'notificationBar': @@ -373,8 +376,6 @@ export default class RuntimeBackground { if (this.onInstalledReason === 'install') { BrowserApi.createNewTab('https://bitwarden.com/browser-start/'); await this.setDefaultSettings(); - } else if (this.onInstalledReason === 'update') { - await this.reseedStorage(); } this.analytics.ga('send', { @@ -397,12 +398,6 @@ export default class RuntimeBackground { return; } - const reseed124Key = 'reseededStorage124'; - const reseeded124 = await this.storageService.get(reseed124Key); - if (reseeded124) { - return; - } - const getStorage = (): Promise => new Promise((resolve) => { chrome.storage.local.get(null, (o: any) => resolve(o)); }); @@ -418,11 +413,8 @@ export default class RuntimeBackground { if (!storage.hasOwnProperty(key)) { continue; } - await this.storageService.save(key, storage[key]); } - - await this.storageService.save(reseed124Key, true); } private async setDefaultSettings() { diff --git a/src/popup/settings/settings.component.html b/src/popup/settings/settings.component.html index ac597216018..21ba4084043 100644 --- a/src/popup/settings/settings.component.html +++ b/src/popup/settings/settings.component.html @@ -26,7 +26,8 @@
-
diff --git a/src/popup/settings/settings.component.ts b/src/popup/settings/settings.component.ts index 92e86ecbcd8..e54d33d9da1 100644 --- a/src/popup/settings/settings.component.ts +++ b/src/popup/settings/settings.component.ts @@ -3,7 +3,9 @@ import swal from 'sweetalert'; import { Component, + ElementRef, OnInit, + ViewChild, } from '@angular/core'; import { Router } from '@angular/router'; @@ -40,8 +42,10 @@ const RateUrls = { templateUrl: 'settings.component.html', }) export class SettingsComponent implements OnInit { + @ViewChild('lockOptionsSelect', { read: ElementRef }) lockOptionsSelectRef: ElementRef; lockOptions: any[]; lockOption: number = null; + previousLockOption: number = null; constructor(private platformUtilsService: PlatformUtilsService, private i18nService: I18nService, private analytics: Angulartics2, private lockService: LockService, @@ -79,10 +83,29 @@ export class SettingsComponent implements OnInit { } this.lockOption = option; } + this.previousLockOption = this.lockOption; } - async saveLockOption() { + async saveLockOption(newValue: number) { + if (newValue == null) { + const confirmed = await this.platformUtilsService.showDialog( + this.i18nService.t('neverLockWarning'), null, + this.i18nService.t('yes'), this.i18nService.t('cancel'), 'warning'); + if (!confirmed) { + this.lockOptions.forEach((option: any, i) => { + if (option.value === this.lockOption) { + this.lockOptionsSelectRef.nativeElement.value = i + ': ' + this.lockOption; + } + }); + return; + } + } + this.previousLockOption = this.lockOption; + this.lockOption = newValue; await this.lockService.setLockOption(this.lockOption != null ? this.lockOption : null); + if (this.previousLockOption == null) { + this.messagingService.send('bgReseedStorage'); + } } async lock() {