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