Skip to content

Commit

Permalink
[BWA-82] Don't Timeout When User Selects Never (#212)
Browse files Browse the repository at this point in the history
  • Loading branch information
brant-livefront authored Dec 12, 2024
1 parent d941bd1 commit f124b31
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
13 changes: 13 additions & 0 deletions AuthenticatorShared/Core/Platform/Services/StateService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class MockStateService: StateService {
var timeProvider = MockTimeProvider(.currentTime)
var showWebIcons = true
var showWebIconsSubject = CurrentValueSubject<Bool, Never>(true)
var vaultTimeout = SessionTimeoutValue.never

lazy var appThemeSubject = CurrentValueSubject<AppTheme, Never>(self.appTheme ?? .default)

Expand Down Expand Up @@ -54,6 +55,10 @@ class MockStateService: StateService {
showWebIcons
}

func getVaultTimeout() async -> SessionTimeoutValue {
vaultTimeout
}

func setAppTheme(_ appTheme: AppTheme) async {
self.appTheme = appTheme
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit f124b31

Please sign in to comment.