mirror of
https://github.com/bitwarden/mobile.git
synced 2024-12-26 16:57:59 +01:00
update autofill identities if needed
This commit is contained in:
parent
e407acd2a7
commit
13ddd10c40
@ -6,6 +6,9 @@ using Bit.iOS.Core.Controllers;
|
||||
using Bit.App.Resources;
|
||||
using Bit.iOS.Core.Views;
|
||||
using Bit.iOS.Autofill.Utilities;
|
||||
using Bit.iOS.Core.Utilities;
|
||||
using Bit.Core.Utilities;
|
||||
using Bit.Core.Abstractions;
|
||||
|
||||
namespace Bit.iOS.Autofill
|
||||
{
|
||||
@ -28,6 +31,14 @@ namespace Bit.iOS.Autofill
|
||||
TableView.EstimatedRowHeight = 44;
|
||||
TableView.Source = new TableSource(this);
|
||||
await ((TableSource)TableView.Source).LoadItemsAsync();
|
||||
|
||||
var storageService = ServiceContainer.Resolve<IStorageService>("storageService");
|
||||
var needsAutofillReplacement = await storageService.GetAsync<bool?>(
|
||||
Core.Constants.AutofillNeedsIdentityReplacementKey);
|
||||
if(needsAutofillReplacement.GetValueOrDefault())
|
||||
{
|
||||
await ASHelpers.ReplaceAllIdentities();
|
||||
}
|
||||
}
|
||||
|
||||
partial void CancelBarButton_Activated(UIBarButtonItem sender)
|
||||
|
@ -28,5 +28,7 @@
|
||||
public const string UTTypeAppExtensionFillWebViewAction = "org.appextension.fill-webview-action";
|
||||
public const string UTTypeAppExtensionFillBrowserAction = "org.appextension.fill-browser-action";
|
||||
public const string UTTypeAppExtensionSetup = "com.8bit.bitwarden.extension-setup";
|
||||
|
||||
public const string AutofillNeedsIdentityReplacementKey = "autofillNeedsIdentityReplacement";
|
||||
}
|
||||
}
|
||||
|
@ -12,9 +12,16 @@ namespace Bit.iOS.Core.Utilities
|
||||
{
|
||||
public static async Task ReplaceAllIdentities()
|
||||
{
|
||||
var cipherService = ServiceContainer.Resolve<ICipherService>("cipherService");
|
||||
if(await AutofillEnabled())
|
||||
{
|
||||
var storageService = ServiceContainer.Resolve<IStorageService>("storageService");
|
||||
var lockService = ServiceContainer.Resolve<ILockService>("lockService");
|
||||
if(await lockService.IsLockedAsync())
|
||||
{
|
||||
await storageService.SaveAsync(Constants.AutofillNeedsIdentityReplacementKey, true);
|
||||
return;
|
||||
}
|
||||
var cipherService = ServiceContainer.Resolve<ICipherService>("cipherService");
|
||||
var identities = new List<ASPasswordCredentialIdentity>();
|
||||
var ciphers = await cipherService.GetAllDecryptedAsync();
|
||||
foreach(var cipher in ciphers)
|
||||
@ -28,6 +35,7 @@ namespace Bit.iOS.Core.Utilities
|
||||
if(identities.Any())
|
||||
{
|
||||
await ASCredentialIdentityStore.SharedStore?.ReplaceCredentialIdentitiesAsync(identities.ToArray());
|
||||
await storageService.SaveAsync(Constants.AutofillNeedsIdentityReplacementKey, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -96,6 +96,15 @@ namespace Bit.iOS
|
||||
{
|
||||
ListenYubiKey((bool)message.Data);
|
||||
}
|
||||
else if(message.Command == "unlocked")
|
||||
{
|
||||
var needsAutofillReplacement = await _storageService.GetAsync<bool?>(
|
||||
Core.Constants.AutofillNeedsIdentityReplacementKey);
|
||||
if(needsAutofillReplacement.GetValueOrDefault())
|
||||
{
|
||||
await ASHelpers.ReplaceAllIdentities();
|
||||
}
|
||||
}
|
||||
else if(message.Command == "showAppExtension")
|
||||
{
|
||||
Device.BeginInvokeOnMainThread(() => ShowAppExtension((ExtensionPageViewModel)message.Data));
|
||||
|
Loading…
Reference in New Issue
Block a user