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:
parent
4b4e847816
commit
f385c3773c
@ -115,6 +115,7 @@ containerService.attachToWindow(window);
|
|||||||
|
|
||||||
export function initFactory(): Function {
|
export function initFactory(): Function {
|
||||||
return async () => {
|
return async () => {
|
||||||
|
await (storageService as HtmlStorageService).init();
|
||||||
const isDev = platformUtilsService.isDev();
|
const isDev = platformUtilsService.isDev();
|
||||||
if (!isDev && platformUtilsService.isSelfHost()) {
|
if (!isDev && platformUtilsService.isSelfHost()) {
|
||||||
environmentService.baseUrl = window.location.origin;
|
environmentService.baseUrl = window.location.origin;
|
||||||
|
@ -3,6 +3,17 @@
|
|||||||
</div>
|
</div>
|
||||||
<p>{{'optionsDesc' | i18n}}</p>
|
<p>{{'optionsDesc' | i18n}}</p>
|
||||||
<form (ngSubmit)="submit()" ngNativeValidate>
|
<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="row">
|
||||||
<div class="col-6">
|
<div class="col-6">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
@ -7,6 +7,7 @@ import { ToasterService } from 'angular2-toaster';
|
|||||||
import { Angulartics2 } from 'angulartics2';
|
import { Angulartics2 } from 'angulartics2';
|
||||||
|
|
||||||
import { I18nService } from 'jslib/abstractions/i18n.service';
|
import { I18nService } from 'jslib/abstractions/i18n.service';
|
||||||
|
import { LockService } from 'jslib/abstractions/lock.service';
|
||||||
import { StateService } from 'jslib/abstractions/state.service';
|
import { StateService } from 'jslib/abstractions/state.service';
|
||||||
import { StorageService } from 'jslib/abstractions/storage.service';
|
import { StorageService } from 'jslib/abstractions/storage.service';
|
||||||
|
|
||||||
@ -19,15 +20,27 @@ import { Utils } from 'jslib/misc/utils';
|
|||||||
templateUrl: 'options.component.html',
|
templateUrl: 'options.component.html',
|
||||||
})
|
})
|
||||||
export class OptionsComponent implements OnInit {
|
export class OptionsComponent implements OnInit {
|
||||||
|
lockOption: number = null;
|
||||||
disableIcons: boolean;
|
disableIcons: boolean;
|
||||||
locale: string;
|
locale: string;
|
||||||
|
lockOptions: any[];
|
||||||
localeOptions: any[];
|
localeOptions: any[];
|
||||||
|
|
||||||
private startingLocale: string;
|
private startingLocale: string;
|
||||||
|
|
||||||
constructor(private storageService: StorageService, private stateService: StateService,
|
constructor(private storageService: StorageService, private stateService: StateService,
|
||||||
private analytics: Angulartics2, private i18nService: I18nService,
|
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[] = [];
|
const localeOptions: any[] = [];
|
||||||
i18nService.supportedTranslationLocales.forEach((locale) => {
|
i18nService.supportedTranslationLocales.forEach((locale) => {
|
||||||
localeOptions.push({ name: locale, value: locale });
|
localeOptions.push({ name: locale, value: locale });
|
||||||
@ -38,11 +51,13 @@ export class OptionsComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async ngOnInit() {
|
async ngOnInit() {
|
||||||
|
this.lockOption = await this.storageService.get<number>(ConstantsService.lockOptionKey);
|
||||||
this.disableIcons = await this.storageService.get<boolean>(ConstantsService.disableFaviconKey);
|
this.disableIcons = await this.storageService.get<boolean>(ConstantsService.disableFaviconKey);
|
||||||
this.locale = this.startingLocale = await this.storageService.get<string>(ConstantsService.localeKey);
|
this.locale = this.startingLocale = await this.storageService.get<string>(ConstantsService.localeKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
async submit() {
|
async submit() {
|
||||||
|
await this.lockService.setLockOption(this.lockOption != null ? this.lockOption : null);
|
||||||
await this.storageService.save(ConstantsService.disableFaviconKey, this.disableIcons);
|
await this.storageService.save(ConstantsService.disableFaviconKey, this.disableIcons);
|
||||||
await this.stateService.save(ConstantsService.disableFaviconKey, this.disableIcons);
|
await this.stateService.save(ConstantsService.disableFaviconKey, this.disableIcons);
|
||||||
await this.storageService.save(ConstantsService.localeKey, this.locale);
|
await this.storageService.save(ConstantsService.localeKey, this.locale);
|
||||||
|
@ -2350,5 +2350,32 @@
|
|||||||
},
|
},
|
||||||
"filters": {
|
"filters": {
|
||||||
"message": "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"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,13 @@ export class HtmlStorageService implements StorageService {
|
|||||||
ConstantsService.localeKey, ConstantsService.lockOptionKey]);
|
ConstantsService.localeKey, ConstantsService.lockOptionKey]);
|
||||||
private localStorageStartsWithKeys = ['twoFactorToken_'];
|
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> {
|
get<T>(key: string): Promise<T> {
|
||||||
let json: string = null;
|
let json: string = null;
|
||||||
if (this.isLocalStorage(key)) {
|
if (this.isLocalStorage(key)) {
|
||||||
|
@ -94,7 +94,7 @@ export class WebPlatformUtilsService implements PlatformUtilsService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
lockTimeout(): number {
|
lockTimeout(): number {
|
||||||
return 15;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
launchUri(uri: string, options?: any): void {
|
launchUri(uri: string, options?: any): void {
|
||||||
|
Loading…
Reference in New Issue
Block a user