From f124b31a4e51af78b9004882924c64cee1a862eb Mon Sep 17 00:00:00 2001 From: Brant DeBow <125889545+brant-livefront@users.noreply.github.com> Date: Thu, 12 Dec 2024 17:03:05 -0500 Subject: [PATCH] [BWA-82] Don't Timeout When User Selects Never (#212) --- .../Core/Platform/Services/StateService.swift | 13 +++++++++++++ .../Services/TestHelpers/MockStateService.swift | 5 +++++ .../UI/Platform/Application/AppCoordinator.swift | 4 +++- 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/AuthenticatorShared/Core/Platform/Services/StateService.swift b/AuthenticatorShared/Core/Platform/Services/StateService.swift index ebd82651..3c44f4dd 100644 --- a/AuthenticatorShared/Core/Platform/Services/StateService.swift +++ b/AuthenticatorShared/Core/Platform/Services/StateService.swift @@ -70,6 +70,12 @@ protocol StateService: AnyObject { /// func getShowWebIcons() async -> Bool + /// Gets the session timeout value for the logged in user. + /// + /// - Returns: The session timeout value. + /// + func getVaultTimeout() async -> SessionTimeoutValue + /// Sets the app theme. /// /// - Parameter appTheme: The new app theme. @@ -240,6 +246,13 @@ actor DefaultStateService: StateService { !appSettingsStore.disableWebIcons } + func getVaultTimeout() async -> SessionTimeoutValue { + let accountId = await getActiveAccountId() + guard let rawValue = appSettingsStore.vaultTimeout(userId: accountId) else { return .never } + + return SessionTimeoutValue(rawValue: rawValue) + } + func setAppTheme(_ appTheme: AppTheme) async { appSettingsStore.appTheme = appTheme.value appThemeSubject.send(appTheme) diff --git a/AuthenticatorShared/Core/Platform/Services/TestHelpers/MockStateService.swift b/AuthenticatorShared/Core/Platform/Services/TestHelpers/MockStateService.swift index f5fcbc0a..a9bf5bf5 100644 --- a/AuthenticatorShared/Core/Platform/Services/TestHelpers/MockStateService.swift +++ b/AuthenticatorShared/Core/Platform/Services/TestHelpers/MockStateService.swift @@ -24,6 +24,7 @@ class MockStateService: StateService { var timeProvider = MockTimeProvider(.currentTime) var showWebIcons = true var showWebIconsSubject = CurrentValueSubject(true) + var vaultTimeout = SessionTimeoutValue.never lazy var appThemeSubject = CurrentValueSubject(self.appTheme ?? .default) @@ -54,6 +55,10 @@ class MockStateService: StateService { showWebIcons } + func getVaultTimeout() async -> SessionTimeoutValue { + vaultTimeout + } + func setAppTheme(_ appTheme: AppTheme) async { self.appTheme = appTheme } diff --git a/AuthenticatorShared/UI/Platform/Application/AppCoordinator.swift b/AuthenticatorShared/UI/Platform/Application/AppCoordinator.swift index 919826b9..0f16520b 100644 --- a/AuthenticatorShared/UI/Platform/Application/AppCoordinator.swift +++ b/AuthenticatorShared/UI/Platform/Application/AppCoordinator.swift @@ -63,8 +63,10 @@ class AppCoordinator: Coordinator, HasRootNavigator { func handleEvent(_ event: AppEvent, context: AnyObject?) async { switch event { case .didStart: + let hasTimeout = await services.stateService.getVaultTimeout() != .never let isEnabled = await (try? services.biometricsRepository.getBiometricUnlockStatus().isEnabled) ?? false - if isEnabled { + + if isEnabled, hasTimeout { showAuth(.vaultUnlock) } else { showTab(route: .itemList(.list))