Don't build the keyboard index for autofill if using logout action (#943)

* Don't build the keyboard index for autofill if using logout action

* trigger index rebuild on vault timeout changed event
This commit is contained in:
Kyle Spearrin 2020-06-01 14:46:53 -04:00 committed by GitHub
parent 24547e67bf
commit 1120bff34d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 44 additions and 8 deletions

View File

@ -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<SettingsPageListItem>
{
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,

View File

@ -15,6 +15,11 @@ namespace Bit.iOS.Core.Utilities
if (await AutofillEnabled())
{
var storageService = ServiceContainer.Resolve<IStorageService>("storageService");
var timeoutAction = await storageService.GetAsync<string>(Bit.Core.Constants.VaultTimeoutActionKey);
if (timeoutAction == "logOut")
{
return;
}
var vaultTimeoutService = ServiceContainer.Resolve<IVaultTimeoutService>("vaultTimeoutService");
if (await vaultTimeoutService.IsLockedAsync())
{
@ -42,6 +47,12 @@ namespace Bit.iOS.Core.Utilities
public static async Task<bool> IdentitiesCanIncremental()
{
var storageService = ServiceContainer.Resolve<IStorageService>("storageService");
var timeoutAction = await storageService.GetAsync<string>(Bit.Core.Constants.VaultTimeoutActionKey);
if (timeoutAction == "logOut")
{
return false;
}
var state = await ASCredentialIdentityStore.SharedStore?.GetCredentialIdentityStoreStateAsync();
return state != null && state.Enabled && state.SupportsIncrementalUpdates;
}

View File

@ -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<string>(Constants.VaultTimeoutActionKey);
if (timeoutAction == "logOut")
{
await ASCredentialIdentityStore.SharedStore?.RemoveAllCredentialIdentitiesAsync();
}
else
{
await ASHelpers.ReplaceAllIdentities();
}
}
});
return base.FinishedLaunching(app, options);