mirror of
https://github.com/bitwarden/browser
synced 2025-12-15 15:53:27 +00:00
warn user and reseed storage if using Never lock option
This commit is contained in:
@@ -26,7 +26,8 @@
|
||||
<div class="box-content single-line">
|
||||
<div class="box-content-row display-block" appBoxRow>
|
||||
<label for="lockOption">{{'lockOptions' | i18n}}</label>
|
||||
<select id="lockOption" name="LockOptions" [(ngModel)]="lockOption" (change)="saveLockOption()">
|
||||
<select #lockOptionsSelect id="lockOption" name="LockOptions" [ngModel]="lockOption"
|
||||
(ngModelChange)="saveLockOption($event)">
|
||||
<option *ngFor="let o of lockOptions" [ngValue]="o.value">{{o.name}}</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user