diff --git a/src/App/Pages/Settings/SettingsPage/SettingsPageViewModel.cs b/src/App/Pages/Settings/SettingsPage/SettingsPageViewModel.cs index 0ca80995a..81526ceed 100644 --- a/src/App/Pages/Settings/SettingsPage/SettingsPageViewModel.cs +++ b/src/App/Pages/Settings/SettingsPage/SettingsPageViewModel.cs @@ -112,7 +112,7 @@ namespace Bit.App.Pages { fingerprint = await _cryptoService.GetFingerprintAsync(await _userService.GetUserIdAsync()); } - catch (Exception e) when(e.Message == "No public key available.") + catch (Exception e) when (e.Message == "No public key available.") { return; } @@ -193,8 +193,10 @@ namespace Bit.App.Pages public async Task VaultTimeoutAsync() { - var options = _vaultTimeouts.Select(o => o.Key == _vaultTimeoutDisplayValue ? $"✓ {o.Key}" : o.Key).ToArray(); - var selection = await Page.DisplayActionSheet(AppResources.VaultTimeout, AppResources.Cancel, null, options); + var options = _vaultTimeouts.Select( + o => o.Key == _vaultTimeoutDisplayValue ? $"✓ {o.Key}" : o.Key).ToArray(); + var selection = await Page.DisplayActionSheet(AppResources.VaultTimeout, + AppResources.Cancel, null, options); if (selection == null || selection == AppResources.Cancel) { return; @@ -206,11 +208,13 @@ namespace Bit.App.Pages GetVaultTimeoutActionFromKey(_vaultTimeoutActionDisplayValue)); BuildList(); } - + public async Task VaultTimeoutActionAsync() { - var options = _vaultTimeoutActions.Select(o => o.Key == _vaultTimeoutActionDisplayValue ? $"✓ {o.Key}" : o.Key).ToArray(); - var selection = await Page.DisplayActionSheet(AppResources.VaultTimeoutAction, AppResources.Cancel, null, options); + var options = _vaultTimeoutActions.Select(o => + o.Key == _vaultTimeoutActionDisplayValue ? $"✓ {o.Key}" : o.Key).ToArray(); + var selection = await Page.DisplayActionSheet(AppResources.VaultTimeoutAction, + AppResources.Cancel, null, options); if (selection == null || selection == AppResources.Cancel) { return; @@ -227,6 +231,10 @@ namespace Bit.App.Pages } } var selectionOption = _vaultTimeoutActions.FirstOrDefault(o => o.Key == cleanSelection); + if(_vaultTimeoutActionDisplayValue != selectionOption.Key) + { + _messagingService.Send("vaultTimeoutActionChanged"); + } _vaultTimeoutActionDisplayValue = selectionOption.Key; await _vaultTimeoutService.SetVaultTimeoutOptionsAsync(GetVaultTimeoutFromKey(_vaultTimeoutDisplayValue), selectionOption.Value); @@ -349,7 +357,11 @@ namespace Bit.App.Pages var securityItems = new List { new SettingsPageListItem { Name = AppResources.VaultTimeout, SubLabel = _vaultTimeoutDisplayValue }, - new SettingsPageListItem { Name = AppResources.VaultTimeoutAction, SubLabel = _vaultTimeoutActionDisplayValue }, + new SettingsPageListItem + { + Name = AppResources.VaultTimeoutAction, + SubLabel = _vaultTimeoutActionDisplayValue + }, new SettingsPageListItem { Name = AppResources.UnlockWithPIN, diff --git a/src/iOS.Core/Utilities/ASHelpers.cs b/src/iOS.Core/Utilities/ASHelpers.cs index 72a234874..38579ebcf 100644 --- a/src/iOS.Core/Utilities/ASHelpers.cs +++ b/src/iOS.Core/Utilities/ASHelpers.cs @@ -15,6 +15,11 @@ namespace Bit.iOS.Core.Utilities if (await AutofillEnabled()) { var storageService = ServiceContainer.Resolve("storageService"); + var timeoutAction = await storageService.GetAsync(Bit.Core.Constants.VaultTimeoutActionKey); + if (timeoutAction == "logOut") + { + return; + } var vaultTimeoutService = ServiceContainer.Resolve("vaultTimeoutService"); if (await vaultTimeoutService.IsLockedAsync()) { @@ -42,6 +47,12 @@ namespace Bit.iOS.Core.Utilities public static async Task IdentitiesCanIncremental() { + var storageService = ServiceContainer.Resolve("storageService"); + var timeoutAction = await storageService.GetAsync(Bit.Core.Constants.VaultTimeoutActionKey); + if (timeoutAction == "logOut") + { + return false; + } var state = await ASCredentialIdentityStore.SharedStore?.GetCredentialIdentityStoreStateAsync(); return state != null && state.Enabled && state.SupportsIncrementalUpdates; } diff --git a/src/iOS/AppDelegate.cs b/src/iOS/AppDelegate.cs index 96912f385..a4a161768 100644 --- a/src/iOS/AppDelegate.cs +++ b/src/iOS/AppDelegate.cs @@ -120,7 +120,8 @@ namespace Bit.iOS } } } - else if (message.Command == "addedCipher" || message.Command == "editedCipher" || message.Command == "restoredCipher") + else if (message.Command == "addedCipher" || message.Command == "editedCipher" || + message.Command == "restoredCipher") { if (_deviceActionService.SystemMajorVersion() >= 12) { @@ -173,6 +174,18 @@ namespace Bit.iOS { await ASHelpers.ReplaceAllIdentities(); } + else if (message.Command == "vaultTimeoutActionChanged") + { + var timeoutAction = await _storageService.GetAsync(Constants.VaultTimeoutActionKey); + if (timeoutAction == "logOut") + { + await ASCredentialIdentityStore.SharedStore?.RemoveAllCredentialIdentitiesAsync(); + } + else + { + await ASHelpers.ReplaceAllIdentities(); + } + } }); return base.FinishedLaunching(app, options);