From 495de59e659c91195e097a6915d10d6aa85a2ca1 Mon Sep 17 00:00:00 2001 From: Bernd Schoolmann Date: Thu, 16 Jan 2025 12:14:59 +0100 Subject: [PATCH 1/4] Fix system authentication setup --- .../src/app/accounts/settings.component.ts | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/apps/desktop/src/app/accounts/settings.component.ts b/apps/desktop/src/app/accounts/settings.component.ts index f3440975cf2..e9aeaaf82b1 100644 --- a/apps/desktop/src/app/accounts/settings.component.ts +++ b/apps/desktop/src/app/accounts/settings.component.ts @@ -362,14 +362,24 @@ export class SettingsComponent implements OnInit, OnDestroy { } }); - this.supportsBiometric = - (await this.biometricsService.getBiometricsStatus()) === BiometricsStatus.Available; + this.supportsBiometric = this.shouldAllowBiometricSetup( + await this.biometricsService.getBiometricsStatus(), + ); this.timerId = setInterval(async () => { - this.supportsBiometric = - (await this.biometricsService.getBiometricsStatus()) === BiometricsStatus.Available; + this.supportsBiometric = this.shouldAllowBiometricSetup( + await this.biometricsService.getBiometricsStatus(), + ); }, 1000); } + private shouldAllowBiometricSetup(biometricStatus: BiometricsStatus): boolean { + return [ + BiometricsStatus.Available, + BiometricsStatus.AutoSetupNeeded, + BiometricsStatus.ManualSetupNeeded, + ].includes(biometricStatus); + } + async saveVaultTimeout(newValue: VaultTimeout) { if (newValue === VaultTimeoutStringType.Never) { const confirmed = await this.dialogService.openSimpleDialog({ @@ -485,6 +495,7 @@ export class SettingsComponent implements OnInit, OnDestroy { } const status = await this.biometricsService.getBiometricsStatus(); + this.logService.info("status", status); if (status === BiometricsStatus.AutoSetupNeeded) { await this.biometricsService.setupBiometrics(); From 9623b5b3c1ac34d989451de408645fd27438179b Mon Sep 17 00:00:00 2001 From: Bernd Schoolmann Date: Thu, 16 Jan 2025 12:16:40 +0100 Subject: [PATCH 2/4] Fix biometric status --- .../src/key-management/biometrics/main-biometrics.service.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/desktop/src/key-management/biometrics/main-biometrics.service.ts b/apps/desktop/src/key-management/biometrics/main-biometrics.service.ts index 06956503a05..d0ba66fdad4 100644 --- a/apps/desktop/src/key-management/biometrics/main-biometrics.service.ts +++ b/apps/desktop/src/key-management/biometrics/main-biometrics.service.ts @@ -60,6 +60,8 @@ export class MainBiometricsService extends DesktopBiometricsService { */ async getBiometricsStatus(): Promise { if (!(await this.osBiometricsService.osSupportsBiometric())) { + return BiometricsStatus.HardwareUnavailable; + } else { if (await this.osBiometricsService.osBiometricsNeedsSetup()) { if (await this.osBiometricsService.osBiometricsCanAutoSetup()) { return BiometricsStatus.AutoSetupNeeded; @@ -67,8 +69,6 @@ export class MainBiometricsService extends DesktopBiometricsService { return BiometricsStatus.ManualSetupNeeded; } } - - return BiometricsStatus.HardwareUnavailable; } return BiometricsStatus.Available; } From 84e9fe47cda3dddd3d6929d4edb7c1a19ad85c29 Mon Sep 17 00:00:00 2001 From: Bernd Schoolmann Date: Thu, 16 Jan 2025 12:18:54 +0100 Subject: [PATCH 3/4] Remove debug log --- apps/desktop/src/app/accounts/settings.component.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/apps/desktop/src/app/accounts/settings.component.ts b/apps/desktop/src/app/accounts/settings.component.ts index e9aeaaf82b1..d35845fa6aa 100644 --- a/apps/desktop/src/app/accounts/settings.component.ts +++ b/apps/desktop/src/app/accounts/settings.component.ts @@ -495,7 +495,6 @@ export class SettingsComponent implements OnInit, OnDestroy { } const status = await this.biometricsService.getBiometricsStatus(); - this.logService.info("status", status); if (status === BiometricsStatus.AutoSetupNeeded) { await this.biometricsService.setupBiometrics(); From 8635715e4634ea2391653f351b0dc3974b9497d2 Mon Sep 17 00:00:00 2001 From: Bernd Schoolmann Date: Thu, 16 Jan 2025 16:52:40 +0100 Subject: [PATCH 4/4] Fix tests --- .../biometrics/biometrics.service.spec.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/desktop/src/key-management/biometrics/biometrics.service.spec.ts b/apps/desktop/src/key-management/biometrics/biometrics.service.spec.ts index e69ebca3630..9e5755dd579 100644 --- a/apps/desktop/src/key-management/biometrics/biometrics.service.spec.ts +++ b/apps/desktop/src/key-management/biometrics/biometrics.service.spec.ts @@ -117,15 +117,15 @@ describe("biometrics tests", function () { const testCases = [ // happy path [true, false, false, BiometricsStatus.Available], - [false, true, true, BiometricsStatus.AutoSetupNeeded], - [false, true, false, BiometricsStatus.ManualSetupNeeded], - [false, false, false, BiometricsStatus.HardwareUnavailable], + [false, true, true, BiometricsStatus.HardwareUnavailable], + [true, true, true, BiometricsStatus.AutoSetupNeeded], + [true, true, false, BiometricsStatus.ManualSetupNeeded], // should not happen [false, false, true, BiometricsStatus.HardwareUnavailable], - [true, true, true, BiometricsStatus.Available], - [true, true, false, BiometricsStatus.Available], [true, false, true, BiometricsStatus.Available], + [false, true, false, BiometricsStatus.HardwareUnavailable], + [false, false, false, BiometricsStatus.HardwareUnavailable], ]; for (const [supportsBiometric, needsSetup, canAutoSetup, expected] of testCases) {