Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BWA-82] Don't Timeout When User Selects Never #212

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading