1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-28 12:45:45 +01:00

allow users to change lock options, default to 15 min

This commit is contained in:
Kyle Spearrin 2018-07-27 15:08:59 -04:00
parent 4b4e847816
commit f385c3773c
6 changed files with 63 additions and 2 deletions

View File

@ -115,6 +115,7 @@ containerService.attachToWindow(window);
export function initFactory(): Function {
return async () => {
await (storageService as HtmlStorageService).init();
const isDev = platformUtilsService.isDev();
if (!isDev && platformUtilsService.isSelfHost()) {
environmentService.baseUrl = window.location.origin;

View File

@ -3,6 +3,17 @@
</div>
<p>{{'optionsDesc' | i18n}}</p>
<form (ngSubmit)="submit()" ngNativeValidate>
<div class="row">
<div class="col-6">
<div class="form-group">
<label for="lockOption">{{'lockOptions' | i18n}}</label>
<select id="lockOption" name="LockOption" [(ngModel)]="lockOption" class="form-control">
<option *ngFor="let o of lockOptions" [ngValue]="o.value">{{o.name}}</option>
</select>
<small class="form-text text-muted">{{'lockOptionsDesc' | i18n}}</small>
</div>
</div>
</div>
<div class="row">
<div class="col-6">
<div class="form-group">

View File

@ -7,6 +7,7 @@ import { ToasterService } from 'angular2-toaster';
import { Angulartics2 } from 'angulartics2';
import { I18nService } from 'jslib/abstractions/i18n.service';
import { LockService } from 'jslib/abstractions/lock.service';
import { StateService } from 'jslib/abstractions/state.service';
import { StorageService } from 'jslib/abstractions/storage.service';
@ -19,15 +20,27 @@ import { Utils } from 'jslib/misc/utils';
templateUrl: 'options.component.html',
})
export class OptionsComponent implements OnInit {
lockOption: number = null;
disableIcons: boolean;
locale: string;
lockOptions: any[];
localeOptions: any[];
private startingLocale: string;
constructor(private storageService: StorageService, private stateService: StateService,
private analytics: Angulartics2, private i18nService: I18nService,
private toasterService: ToasterService) {
private toasterService: ToasterService, private lockService: LockService) {
this.lockOptions = [
{ name: i18nService.t('oneMinute'), value: 1 },
{ name: i18nService.t('fiveMinutes'), value: 5 },
{ name: i18nService.t('fifteenMinutes'), value: 15 },
{ name: i18nService.t('thirtyMinutes'), value: 30 },
{ name: i18nService.t('oneHour'), value: 60 },
{ name: i18nService.t('fourHours'), value: 240 },
{ name: i18nService.t('onRefresh'), value: -1 },
];
const localeOptions: any[] = [];
i18nService.supportedTranslationLocales.forEach((locale) => {
localeOptions.push({ name: locale, value: locale });
@ -38,11 +51,13 @@ export class OptionsComponent implements OnInit {
}
async ngOnInit() {
this.lockOption = await this.storageService.get<number>(ConstantsService.lockOptionKey);
this.disableIcons = await this.storageService.get<boolean>(ConstantsService.disableFaviconKey);
this.locale = this.startingLocale = await this.storageService.get<string>(ConstantsService.localeKey);
}
async submit() {
await this.lockService.setLockOption(this.lockOption != null ? this.lockOption : null);
await this.storageService.save(ConstantsService.disableFaviconKey, this.disableIcons);
await this.stateService.save(ConstantsService.disableFaviconKey, this.disableIcons);
await this.storageService.save(ConstantsService.localeKey, this.locale);

View File

@ -2350,5 +2350,32 @@
},
"filters": {
"message": "Filters"
},
"lockOptions": {
"message": "Lock Options"
},
"lockOptionsDesc": {
"message": "Choose when your vault locks. A locked vault requires that you re-enter your master password to access it again."
},
"oneMinute": {
"message": "1 minute"
},
"fiveMinutes": {
"message": "5 minutes"
},
"fifteenMinutes": {
"message": "15 minutes"
},
"thirtyMinutes": {
"message": "30 minutes"
},
"oneHour": {
"message": "1 hour"
},
"fourHours": {
"message": "4 hours"
},
"onRefresh": {
"message": "On Refresh"
}
}

View File

@ -7,6 +7,13 @@ export class HtmlStorageService implements StorageService {
ConstantsService.localeKey, ConstantsService.lockOptionKey]);
private localStorageStartsWithKeys = ['twoFactorToken_'];
async init() {
const lockOption = await this.get<number>(ConstantsService.lockOptionKey);
if (lockOption == null) {
await this.save(ConstantsService.lockOptionKey, 15);
}
}
get<T>(key: string): Promise<T> {
let json: string = null;
if (this.isLocalStorage(key)) {

View File

@ -94,7 +94,7 @@ export class WebPlatformUtilsService implements PlatformUtilsService {
}
lockTimeout(): number {
return 15;
return null;
}
launchUri(uri: string, options?: any): void {