mirror of
https://github.com/bitwarden/browser.git
synced 2024-12-25 16:59:17 +01:00
implement hasKey helper
This commit is contained in:
parent
eda99e4f12
commit
3303e60b40
@ -20,8 +20,8 @@ export class AuthGuardService implements CanActivate {
|
||||
return false;
|
||||
}
|
||||
|
||||
const key = await this.cryptoService.getKey();
|
||||
if (key == null) {
|
||||
const hasKey = await this.cryptoService.hasKey();
|
||||
if (!hasKey) {
|
||||
this.router.navigate(['lock']);
|
||||
return false;
|
||||
}
|
||||
|
@ -60,8 +60,8 @@ export class ApiService implements ApiServiceAbstraction {
|
||||
|
||||
/* tslint:disable */
|
||||
// Desktop
|
||||
//this.baseUrl = 'http://localhost:4000';
|
||||
//this.identityBaseUrl = 'http://localhost:33656';
|
||||
this.baseUrl = 'http://localhost:4000';
|
||||
this.identityBaseUrl = 'http://localhost:33656';
|
||||
|
||||
// Desktop HTTPS
|
||||
//this.baseUrl = 'https://localhost:44377';
|
||||
@ -76,13 +76,15 @@ export class ApiService implements ApiServiceAbstraction {
|
||||
//this.identityBaseUrl = 'https://preview-identity.bitwarden.com';
|
||||
|
||||
// Production
|
||||
/*
|
||||
if (this.isWebClient) {
|
||||
this.baseUrl = 'https://vault.bitwarden.com/api';
|
||||
this.identityBaseUrl = 'https://vault.bitwarden.com/identity';
|
||||
this.baseUrl = 'https://api.bitwarden.com';
|
||||
this.identityBaseUrl = 'https://identity.bitwarden.com';
|
||||
} else {
|
||||
this.baseUrl = 'https://api.bitwarden.com';
|
||||
this.identityBaseUrl = 'https://identity.bitwarden.com';
|
||||
}
|
||||
*/
|
||||
/* tslint:enable */
|
||||
}
|
||||
|
||||
|
@ -179,8 +179,8 @@ export class CipherService implements CipherServiceAbstraction {
|
||||
}
|
||||
|
||||
const decCiphers: CipherView[] = [];
|
||||
const key = await this.cryptoService.getKey();
|
||||
if (key == null) {
|
||||
const hasKey = await this.cryptoService.hasKey();
|
||||
if (!hasKey) {
|
||||
throw new Error('No key.');
|
||||
}
|
||||
|
||||
|
@ -54,8 +54,8 @@ export class CollectionService implements CollectionServiceAbstraction {
|
||||
return this.decryptedCollectionCache;
|
||||
}
|
||||
|
||||
const key = await this.cryptoService.getKey();
|
||||
if (key == null) {
|
||||
const hasKey = await this.cryptoService.hasKey();
|
||||
if (!hasKey) {
|
||||
throw new Error('No key.');
|
||||
}
|
||||
|
||||
|
@ -67,8 +67,8 @@ export class FolderService implements FolderServiceAbstraction {
|
||||
return this.decryptedFolderCache;
|
||||
}
|
||||
|
||||
const key = await this.cryptoService.getKey();
|
||||
if (key == null) {
|
||||
const hasKey = await this.cryptoService.hasKey();
|
||||
if (!hasKey) {
|
||||
throw new Error('No key.');
|
||||
}
|
||||
|
||||
|
@ -36,8 +36,8 @@ export class LockService implements LockServiceAbstraction {
|
||||
return;
|
||||
}
|
||||
|
||||
const key = await this.cryptoService.getKey();
|
||||
if (key == null) {
|
||||
const hasKey = await this.cryptoService.hasKey();
|
||||
if (!hasKey) {
|
||||
// no key so no need to lock
|
||||
return;
|
||||
}
|
||||
|
@ -169,7 +169,7 @@ export class PasswordGenerationService implements PasswordGenerationServiceAbstr
|
||||
}
|
||||
|
||||
async getHistory(): Promise<PasswordHistory[]> {
|
||||
const hasKey = (await this.cryptoService.getKey()) != null;
|
||||
const hasKey = await this.cryptoService.hasKey();
|
||||
if (!hasKey) {
|
||||
return new Array<PasswordHistory>();
|
||||
}
|
||||
@ -184,7 +184,7 @@ export class PasswordGenerationService implements PasswordGenerationServiceAbstr
|
||||
|
||||
async addHistory(password: string): Promise<any> {
|
||||
// Cannot add new history if no key is available
|
||||
const hasKey = (await this.cryptoService.getKey()) != null;
|
||||
const hasKey = await this.cryptoService.hasKey();
|
||||
if (!hasKey) {
|
||||
return;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user