implement hasKey helper

This commit is contained in:
Kyle Spearrin 2018-06-13 17:14:26 -04:00
parent eda99e4f12
commit 3303e60b40
7 changed files with 18 additions and 16 deletions

View File

@ -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;
}

View File

@ -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 */
}

View File

@ -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.');
}

View File

@ -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.');
}

View File

@ -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.');
}

View File

@ -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;
}

View File

@ -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;
}