1
0
mirror of https://github.com/bitwarden/mobile synced 2025-12-22 19:23:58 +00:00

update autofill identities if needed

This commit is contained in:
Kyle Spearrin
2019-07-22 07:09:51 -04:00
parent e407acd2a7
commit 13ddd10c40
4 changed files with 31 additions and 1 deletions

View File

@@ -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";
}
}

View File

@@ -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);
}
}
}