mirror of
https://github.com/bitwarden/mobile.git
synced 2024-12-27 17:08:00 +01:00
Misc fixes for account switching (#1849)
* Misc fixes for account switching * use unique bio integrity key in ShareExtension
This commit is contained in:
parent
507c3faea1
commit
c1748acf39
@ -943,5 +943,10 @@ namespace Bit.Droid.Services
|
||||
var activity = CrossCurrentActivity.Current?.Activity as MainActivity;
|
||||
return activity?.Resources?.Configuration?.FontScale ?? 1;
|
||||
}
|
||||
|
||||
public async Task OnAccountSwitchCompleteAsync()
|
||||
{
|
||||
// for any Android-specific cleanup required after switching accounts
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -46,5 +46,6 @@ namespace Bit.App.Abstractions
|
||||
void CloseMainApp();
|
||||
bool SupportsFido2();
|
||||
float GetSystemFontSizeScale();
|
||||
Task OnAccountSwitchCompleteAsync();
|
||||
}
|
||||
}
|
||||
|
@ -428,7 +428,7 @@ namespace Bit.App
|
||||
});
|
||||
}
|
||||
|
||||
private async Task LockedAsync(string userId, bool autoPromptBiometric)
|
||||
private async Task LockedAsync(string userId, bool userInitiated)
|
||||
{
|
||||
if (!await _stateService.IsActiveAccountAsync(userId))
|
||||
{
|
||||
@ -436,6 +436,7 @@ namespace Bit.App
|
||||
return;
|
||||
}
|
||||
|
||||
var autoPromptBiometric = !userInitiated;
|
||||
if (autoPromptBiometric && Device.RuntimePlatform == Device.iOS)
|
||||
{
|
||||
var vaultTimeout = await _stateService.GetVaultTimeoutAsync();
|
||||
|
@ -29,6 +29,8 @@ namespace Bit.App.Services
|
||||
Constants.iOSAutoFillBiometricIntegrityKey,
|
||||
Constants.iOSExtensionClearCiphersCacheKey,
|
||||
Constants.iOSExtensionBiometricIntegrityKey,
|
||||
Constants.iOSShareExtensionClearCiphersCacheKey,
|
||||
Constants.iOSShareExtensionBiometricIntegrityKey,
|
||||
Constants.RememberedEmailKey,
|
||||
Constants.RememberedOrgIdentifierKey,
|
||||
};
|
||||
|
@ -556,6 +556,8 @@ namespace Bit.App.Utilities
|
||||
var environmentService = ServiceContainer.Resolve<IEnvironmentService>("environmentService");
|
||||
await environmentService.SetUrlsFromStorageAsync();
|
||||
await ClearServiceCacheAsync();
|
||||
var deviceActionService = ServiceContainer.Resolve<IDeviceActionService>("deviceActionService");
|
||||
await deviceActionService.OnAccountSwitchCompleteAsync();
|
||||
}
|
||||
|
||||
public static async Task ClearServiceCacheAsync()
|
||||
|
@ -23,6 +23,8 @@
|
||||
public static string iOSAutoFillBiometricIntegrityKey = "iOSAutoFillBiometricIntegrityState";
|
||||
public static string iOSExtensionClearCiphersCacheKey = "iOSExtensionClearCiphersCache";
|
||||
public static string iOSExtensionBiometricIntegrityKey = "iOSExtensionBiometricIntegrityState";
|
||||
public static string iOSShareExtensionClearCiphersCacheKey = "iOSShareExtensionClearCiphersCache";
|
||||
public static string iOSShareExtensionBiometricIntegrityKey = "iOSShareExtensionBiometricIntegrityState";
|
||||
public static string EventCollectionKey = "eventCollection";
|
||||
public static string RememberedEmailKey = "rememberedEmail";
|
||||
public static string RememberedOrgIdentifierKey = "rememberedOrgIdentifier";
|
||||
@ -39,7 +41,8 @@
|
||||
{
|
||||
ClearCiphersCacheKey,
|
||||
iOSAutoFillClearCiphersCacheKey,
|
||||
iOSExtensionClearCiphersCacheKey
|
||||
iOSExtensionClearCiphersCacheKey,
|
||||
iOSShareExtensionClearCiphersCacheKey
|
||||
};
|
||||
|
||||
public static string CiphersKey(string userId) => $"ciphers_{userId}";
|
||||
|
@ -594,6 +594,11 @@ namespace Bit.iOS.Core.Services
|
||||
return scaledHeight / tempHeight;
|
||||
}
|
||||
|
||||
public async Task OnAccountSwitchCompleteAsync()
|
||||
{
|
||||
await ASHelpers.ReplaceAllIdentities();
|
||||
}
|
||||
|
||||
public class PickerDelegate : UIDocumentPickerDelegate
|
||||
{
|
||||
private readonly DeviceActionService _deviceActionService;
|
||||
|
@ -20,11 +20,13 @@ namespace Bit.iOS.Core.Utilities
|
||||
var timeoutAction = await stateService.GetVaultTimeoutActionAsync();
|
||||
if (timeoutAction == VaultTimeoutAction.Logout)
|
||||
{
|
||||
await ASCredentialIdentityStore.SharedStore?.RemoveAllCredentialIdentitiesAsync();
|
||||
return;
|
||||
}
|
||||
var vaultTimeoutService = ServiceContainer.Resolve<IVaultTimeoutService>("vaultTimeoutService");
|
||||
if (await vaultTimeoutService.IsLockedAsync())
|
||||
{
|
||||
await ASCredentialIdentityStore.SharedStore?.RemoveAllCredentialIdentitiesAsync();
|
||||
await storageService.SaveAsync(Constants.AutofillNeedsIdentityReplacementKey, true);
|
||||
return;
|
||||
}
|
||||
@ -43,7 +45,9 @@ namespace Bit.iOS.Core.Utilities
|
||||
{
|
||||
await ASCredentialIdentityStore.SharedStore?.ReplaceCredentialIdentitiesAsync(identities.ToArray());
|
||||
await storageService.SaveAsync(Constants.AutofillNeedsIdentityReplacementKey, false);
|
||||
return;
|
||||
}
|
||||
await ASCredentialIdentityStore.SharedStore?.RemoveAllCredentialIdentitiesAsync();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@ namespace Bit.iOS.ShareExtension
|
||||
private NFCNdefReaderSession _nfcSession = null;
|
||||
private Core.NFCReaderDelegate _nfcDelegate = null;
|
||||
|
||||
readonly LazyResolve<IStateService> _stateService = new LazyResolve<IStateService>("stateervice");
|
||||
readonly LazyResolve<IStateService> _stateService = new LazyResolve<IStateService>("stateService");
|
||||
readonly LazyResolve<IVaultTimeoutService> _vaultTimeoutService = new LazyResolve<IVaultTimeoutService>("vaultTimeoutService");
|
||||
readonly LazyResolve<IDeviceActionService> _deviceActionService = new LazyResolve<IDeviceActionService>("deviceActionService");
|
||||
readonly LazyResolve<IEventService> _eventService = new LazyResolve<IEventService>("eventService");
|
||||
@ -215,7 +215,7 @@ namespace Bit.iOS.ShareExtension
|
||||
iOSCoreHelpers.RegisterLocalServices();
|
||||
var messagingService = ServiceContainer.Resolve<IMessagingService>("messagingService");
|
||||
ServiceContainer.Init(_deviceActionService.Value.DeviceUserAgent,
|
||||
Bit.Core.Constants.iOSExtensionClearCiphersCacheKey, Bit.Core.Constants.iOSAllClearCipherCacheKeys);
|
||||
Bit.Core.Constants.iOSShareExtensionClearCiphersCacheKey, Bit.Core.Constants.iOSAllClearCipherCacheKeys);
|
||||
if (!_initedAppCenter)
|
||||
{
|
||||
iOSCoreHelpers.RegisterAppCenter();
|
||||
|
@ -9,7 +9,7 @@ namespace Bit.iOS.ShareExtension
|
||||
public LockPasswordViewController(IntPtr handle)
|
||||
: base(handle)
|
||||
{
|
||||
BiometricIntegrityKey = Bit.Core.Constants.iOSExtensionBiometricIntegrityKey;
|
||||
BiometricIntegrityKey = Bit.Core.Constants.iOSShareExtensionBiometricIntegrityKey;
|
||||
DismissModalAction = Cancel;
|
||||
}
|
||||
|
||||
|
@ -146,12 +146,7 @@ namespace Bit.iOS
|
||||
{
|
||||
if (_deviceActionService.SystemMajorVersion() >= 12)
|
||||
{
|
||||
var extras = message.Data as Tuple<string, bool, bool>;
|
||||
var userId = extras?.Item1;
|
||||
var userInitiated = extras?.Item2;
|
||||
var expired = extras?.Item3;
|
||||
// TODO make specific to userId
|
||||
// await ASCredentialIdentityStore.SharedStore?.RemoveAllCredentialIdentitiesAsync();
|
||||
await ASCredentialIdentityStore.SharedStore?.RemoveAllCredentialIdentitiesAsync();
|
||||
}
|
||||
}
|
||||
else if ((message.Command == "softDeletedCipher" || message.Command == "restoredCipher")
|
||||
@ -164,9 +159,7 @@ namespace Bit.iOS
|
||||
var timeoutAction = await _stateService.GetVaultTimeoutActionAsync();
|
||||
if (timeoutAction == VaultTimeoutAction.Logout)
|
||||
{
|
||||
var userId = await _stateService.GetActiveUserIdAsync();
|
||||
// TODO make specific to userId
|
||||
// await ASCredentialIdentityStore.SharedStore?.RemoveAllCredentialIdentitiesAsync();
|
||||
await ASCredentialIdentityStore.SharedStore?.RemoveAllCredentialIdentitiesAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user