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()); 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; return;
} }
@ -193,8 +193,10 @@ namespace Bit.App.Pages
public async Task VaultTimeoutAsync() public async Task VaultTimeoutAsync()
{ {
var options = _vaultTimeouts.Select(o => o.Key == _vaultTimeoutDisplayValue ? $"✓ {o.Key}" : o.Key).ToArray(); var options = _vaultTimeouts.Select(
var selection = await Page.DisplayActionSheet(AppResources.VaultTimeout, AppResources.Cancel, null, options); 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) if (selection == null || selection == AppResources.Cancel)
{ {
return; return;
@ -209,8 +211,10 @@ namespace Bit.App.Pages
public async Task VaultTimeoutActionAsync() public async Task VaultTimeoutActionAsync()
{ {
var options = _vaultTimeoutActions.Select(o => o.Key == _vaultTimeoutActionDisplayValue ? $"✓ {o.Key}" : o.Key).ToArray(); var options = _vaultTimeoutActions.Select(o =>
var selection = await Page.DisplayActionSheet(AppResources.VaultTimeoutAction, AppResources.Cancel, null, options); 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) if (selection == null || selection == AppResources.Cancel)
{ {
return; return;
@ -227,6 +231,10 @@ namespace Bit.App.Pages
} }
} }
var selectionOption = _vaultTimeoutActions.FirstOrDefault(o => o.Key == cleanSelection); var selectionOption = _vaultTimeoutActions.FirstOrDefault(o => o.Key == cleanSelection);
if(_vaultTimeoutActionDisplayValue != selectionOption.Key)
{
_messagingService.Send("vaultTimeoutActionChanged");
}
_vaultTimeoutActionDisplayValue = selectionOption.Key; _vaultTimeoutActionDisplayValue = selectionOption.Key;
await _vaultTimeoutService.SetVaultTimeoutOptionsAsync(GetVaultTimeoutFromKey(_vaultTimeoutDisplayValue), await _vaultTimeoutService.SetVaultTimeoutOptionsAsync(GetVaultTimeoutFromKey(_vaultTimeoutDisplayValue),
selectionOption.Value); selectionOption.Value);
@ -349,7 +357,11 @@ namespace Bit.App.Pages
var securityItems = new List<SettingsPageListItem> var securityItems = new List<SettingsPageListItem>
{ {
new SettingsPageListItem { Name = AppResources.VaultTimeout, SubLabel = _vaultTimeoutDisplayValue }, new SettingsPageListItem { Name = AppResources.VaultTimeout, SubLabel = _vaultTimeoutDisplayValue },
new SettingsPageListItem { Name = AppResources.VaultTimeoutAction, SubLabel = _vaultTimeoutActionDisplayValue }, new SettingsPageListItem
{
Name = AppResources.VaultTimeoutAction,
SubLabel = _vaultTimeoutActionDisplayValue
},
new SettingsPageListItem new SettingsPageListItem
{ {
Name = AppResources.UnlockWithPIN, Name = AppResources.UnlockWithPIN,

View file

@ -15,6 +15,11 @@ namespace Bit.iOS.Core.Utilities
if (await AutofillEnabled()) if (await AutofillEnabled())
{ {
var storageService = ServiceContainer.Resolve<IStorageService>("storageService"); 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"); var vaultTimeoutService = ServiceContainer.Resolve<IVaultTimeoutService>("vaultTimeoutService");
if (await vaultTimeoutService.IsLockedAsync()) if (await vaultTimeoutService.IsLockedAsync())
{ {
@ -42,6 +47,12 @@ namespace Bit.iOS.Core.Utilities
public static async Task<bool> IdentitiesCanIncremental() 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(); var state = await ASCredentialIdentityStore.SharedStore?.GetCredentialIdentityStoreStateAsync();
return state != null && state.Enabled && state.SupportsIncrementalUpdates; 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) if (_deviceActionService.SystemMajorVersion() >= 12)
{ {
@ -173,6 +174,18 @@ namespace Bit.iOS
{ {
await ASHelpers.ReplaceAllIdentities(); 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); return base.FinishedLaunching(app, options);