diff --git a/src/services/lock.service.ts b/src/services/lock.service.ts index 1576c1582c..941e86f249 100644 --- a/src/services/lock.service.ts +++ b/src/services/lock.service.ts @@ -35,10 +35,10 @@ export class LockService implements LockServiceAbstraction { } async isLocked(): Promise { - if (this.pinLocked) { + const hasKey = await this.cryptoService.hasKey(); + if (hasKey && this.pinLocked) { return true; } - const hasKey = await this.cryptoService.hasKey(); return !hasKey; } @@ -48,13 +48,7 @@ export class LockService implements LockServiceAbstraction { return; } - if (this.pinLocked) { - return; - } - - const hasKey = await this.cryptoService.hasKey(); - if (!hasKey) { - // no key so no need to lock + if (this.isLocked()) { return; } @@ -83,7 +77,11 @@ export class LockService implements LockServiceAbstraction { if (allowSoftLock) { const pinSet = await this.isPinLockSet(); if (pinSet[0]) { - await this.pinLock(); + this.pinLocked = true; + this.messagingService.send('locked'); + if (this.lockedCallback != null) { + await this.lockedCallback(); + } return; } } @@ -119,12 +117,4 @@ export class LockService implements LockServiceAbstraction { clear(): Promise { return this.storageService.remove(ConstantsService.protectedPin); } - - private async pinLock(): Promise { - this.pinLocked = true; - this.messagingService.send('locked'); - if (this.lockedCallback != null) { - await this.lockedCallback(); - } - } }