1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-16 16:23:44 +00:00

cant be pin locked without key

This commit is contained in:
Kyle Spearrin
2019-02-13 22:08:55 -05:00
parent 0bdbfd7984
commit 43872f82cc

View File

@@ -35,10 +35,10 @@ export class LockService implements LockServiceAbstraction {
} }
async isLocked(): Promise<boolean> { async isLocked(): Promise<boolean> {
if (this.pinLocked) { const hasKey = await this.cryptoService.hasKey();
if (hasKey && this.pinLocked) {
return true; return true;
} }
const hasKey = await this.cryptoService.hasKey();
return !hasKey; return !hasKey;
} }
@@ -48,13 +48,7 @@ export class LockService implements LockServiceAbstraction {
return; return;
} }
if (this.pinLocked) { if (this.isLocked()) {
return;
}
const hasKey = await this.cryptoService.hasKey();
if (!hasKey) {
// no key so no need to lock
return; return;
} }
@@ -83,7 +77,11 @@ export class LockService implements LockServiceAbstraction {
if (allowSoftLock) { if (allowSoftLock) {
const pinSet = await this.isPinLockSet(); const pinSet = await this.isPinLockSet();
if (pinSet[0]) { if (pinSet[0]) {
await this.pinLock(); this.pinLocked = true;
this.messagingService.send('locked');
if (this.lockedCallback != null) {
await this.lockedCallback();
}
return; return;
} }
} }
@@ -119,12 +117,4 @@ export class LockService implements LockServiceAbstraction {
clear(): Promise<any> { clear(): Promise<any> {
return this.storageService.remove(ConstantsService.protectedPin); return this.storageService.remove(ConstantsService.protectedPin);
} }
private async pinLock(): Promise<void> {
this.pinLocked = true;
this.messagingService.send('locked');
if (this.lockedCallback != null) {
await this.lockedCallback();
}
}
} }