mirror of
https://github.com/bitwarden/mobile.git
synced 2024-10-01 04:27:39 +02:00
Fix for deadlock in iOS autofill & share extensions (#960)
This commit is contained in:
parent
fd1941cc3e
commit
473e93ea16
@ -41,7 +41,7 @@ namespace Bit.iOS.Autofill
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void PrepareCredentialList(ASCredentialServiceIdentifier[] serviceIdentifiers)
|
public override async void PrepareCredentialList(ASCredentialServiceIdentifier[] serviceIdentifiers)
|
||||||
{
|
{
|
||||||
InitAppIfNeeded();
|
InitAppIfNeeded();
|
||||||
_context.ServiceIdentifiers = serviceIdentifiers;
|
_context.ServiceIdentifiers = serviceIdentifiers;
|
||||||
@ -54,11 +54,11 @@ namespace Bit.iOS.Autofill
|
|||||||
}
|
}
|
||||||
_context.UrlString = uri;
|
_context.UrlString = uri;
|
||||||
}
|
}
|
||||||
if (!IsAuthed())
|
if (! await IsAuthed())
|
||||||
{
|
{
|
||||||
LaunchLoginFlow();
|
LaunchLoginFlow();
|
||||||
}
|
}
|
||||||
else if (IsLocked())
|
else if (await IsLocked())
|
||||||
{
|
{
|
||||||
PerformSegue("lockPasswordSegue", this);
|
PerformSegue("lockPasswordSegue", this);
|
||||||
}
|
}
|
||||||
@ -75,10 +75,10 @@ namespace Bit.iOS.Autofill
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void ProvideCredentialWithoutUserInteraction(ASPasswordCredentialIdentity credentialIdentity)
|
public override async void ProvideCredentialWithoutUserInteraction(ASPasswordCredentialIdentity credentialIdentity)
|
||||||
{
|
{
|
||||||
InitAppIfNeeded();
|
InitAppIfNeeded();
|
||||||
if (!IsAuthed() || IsLocked())
|
if (! await IsAuthed() || await IsLocked())
|
||||||
{
|
{
|
||||||
var err = new NSError(new NSString("ASExtensionErrorDomain"),
|
var err = new NSError(new NSString("ASExtensionErrorDomain"),
|
||||||
Convert.ToInt32(ASExtensionErrorCode.UserInteractionRequired), null);
|
Convert.ToInt32(ASExtensionErrorCode.UserInteractionRequired), null);
|
||||||
@ -86,13 +86,13 @@ namespace Bit.iOS.Autofill
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_context.CredentialIdentity = credentialIdentity;
|
_context.CredentialIdentity = credentialIdentity;
|
||||||
ProvideCredentialAsync().GetAwaiter().GetResult();
|
await ProvideCredentialAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void PrepareInterfaceToProvideCredential(ASPasswordCredentialIdentity credentialIdentity)
|
public override async void PrepareInterfaceToProvideCredential(ASPasswordCredentialIdentity credentialIdentity)
|
||||||
{
|
{
|
||||||
InitAppIfNeeded();
|
InitAppIfNeeded();
|
||||||
if (!IsAuthed())
|
if (! await IsAuthed())
|
||||||
{
|
{
|
||||||
LaunchLoginFlow();
|
LaunchLoginFlow();
|
||||||
return;
|
return;
|
||||||
@ -101,11 +101,11 @@ namespace Bit.iOS.Autofill
|
|||||||
CheckLock(async () => await ProvideCredentialAsync());
|
CheckLock(async () => await ProvideCredentialAsync());
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void PrepareInterfaceForExtensionConfiguration()
|
public override async void PrepareInterfaceForExtensionConfiguration()
|
||||||
{
|
{
|
||||||
InitAppIfNeeded();
|
InitAppIfNeeded();
|
||||||
_context.Configuring = true;
|
_context.Configuring = true;
|
||||||
if (!IsAuthed())
|
if (! await IsAuthed())
|
||||||
{
|
{
|
||||||
LaunchLoginFlow();
|
LaunchLoginFlow();
|
||||||
return;
|
return;
|
||||||
@ -237,9 +237,9 @@ namespace Bit.iOS.Autofill
|
|||||||
CompleteRequest(decCipher.Id, decCipher.Login.Username, decCipher.Login.Password, totpCode);
|
CompleteRequest(decCipher.Id, decCipher.Login.Username, decCipher.Login.Password, totpCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CheckLock(Action notLockedAction)
|
private async void CheckLock(Action notLockedAction)
|
||||||
{
|
{
|
||||||
if (IsLocked())
|
if (await IsLocked())
|
||||||
{
|
{
|
||||||
PerformSegue("lockPasswordSegue", this);
|
PerformSegue("lockPasswordSegue", this);
|
||||||
}
|
}
|
||||||
@ -249,16 +249,16 @@ namespace Bit.iOS.Autofill
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool IsLocked()
|
private Task<bool> IsLocked()
|
||||||
{
|
{
|
||||||
var vaultTimeoutService = ServiceContainer.Resolve<IVaultTimeoutService>("vaultTimeoutService");
|
var vaultTimeoutService = ServiceContainer.Resolve<IVaultTimeoutService>("vaultTimeoutService");
|
||||||
return vaultTimeoutService.IsLockedAsync().GetAwaiter().GetResult();
|
return vaultTimeoutService.IsLockedAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool IsAuthed()
|
private Task<bool> IsAuthed()
|
||||||
{
|
{
|
||||||
var userService = ServiceContainer.Resolve<IUserService>("userService");
|
var userService = ServiceContainer.Resolve<IUserService>("userService");
|
||||||
return userService.IsAuthenticatedAsync().GetAwaiter().GetResult();
|
return userService.IsAuthenticatedAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InitApp()
|
private void InitApp()
|
||||||
|
@ -25,6 +25,7 @@ namespace Bit.iOS.Autofill
|
|||||||
|
|
||||||
ActivatedLabel.Text = AppResources.AutofillActivated;
|
ActivatedLabel.Text = AppResources.AutofillActivated;
|
||||||
ActivatedLabel.Font = UIFont.FromDescriptor(descriptor, descriptor.PointSize * 1.3f);
|
ActivatedLabel.Font = UIFont.FromDescriptor(descriptor, descriptor.PointSize * 1.3f);
|
||||||
|
ActivatedLabel.TextColor = ThemeHelpers.SuccessColor;
|
||||||
|
|
||||||
BackButton.Title = AppResources.Back;
|
BackButton.Title = AppResources.Back;
|
||||||
base.ViewDidLoad();
|
base.ViewDidLoad();
|
||||||
|
@ -6,9 +6,9 @@ using Bit.iOS.Core;
|
|||||||
using Bit.iOS.Extension.Models;
|
using Bit.iOS.Extension.Models;
|
||||||
using MobileCoreServices;
|
using MobileCoreServices;
|
||||||
using Bit.iOS.Core.Utilities;
|
using Bit.iOS.Core.Utilities;
|
||||||
using Bit.App.Resources;
|
|
||||||
using Bit.iOS.Core.Controllers;
|
using Bit.iOS.Core.Controllers;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using Bit.iOS.Core.Models;
|
using Bit.iOS.Core.Models;
|
||||||
using Bit.Core.Utilities;
|
using Bit.Core.Utilities;
|
||||||
using Bit.Core.Abstractions;
|
using Bit.Core.Abstractions;
|
||||||
@ -63,7 +63,7 @@ namespace Bit.iOS.Extension
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void ViewDidAppear(bool animated)
|
public override async void ViewDidAppear(bool animated)
|
||||||
{
|
{
|
||||||
base.ViewDidAppear(animated);
|
base.ViewDidAppear(animated);
|
||||||
if (_context.ProviderType == Constants.UTTypeAppExtensionSetup)
|
if (_context.ProviderType == Constants.UTTypeAppExtensionSetup)
|
||||||
@ -71,12 +71,12 @@ namespace Bit.iOS.Extension
|
|||||||
PerformSegue("setupSegue", this);
|
PerformSegue("setupSegue", this);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!IsAuthed())
|
if (! await IsAuthed())
|
||||||
{
|
{
|
||||||
LaunchLoginFlow();
|
LaunchLoginFlow();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (IsLocked())
|
else if (await IsLocked())
|
||||||
{
|
{
|
||||||
PerformSegue("lockPasswordSegue", this);
|
PerformSegue("lockPasswordSegue", this);
|
||||||
}
|
}
|
||||||
@ -408,16 +408,16 @@ namespace Bit.iOS.Extension
|
|||||||
iOSCoreHelpers.SubscribeBroadcastReceiver(this, _nfcSession, _nfcDelegate);
|
iOSCoreHelpers.SubscribeBroadcastReceiver(this, _nfcSession, _nfcDelegate);
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool IsLocked()
|
private Task<bool> IsLocked()
|
||||||
{
|
{
|
||||||
var vaultTimeoutService = ServiceContainer.Resolve<IVaultTimeoutService>("vaultTimeoutService");
|
var vaultTimeoutService = ServiceContainer.Resolve<IVaultTimeoutService>("vaultTimeoutService");
|
||||||
return vaultTimeoutService.IsLockedAsync().GetAwaiter().GetResult();
|
return vaultTimeoutService.IsLockedAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool IsAuthed()
|
private Task<bool> IsAuthed()
|
||||||
{
|
{
|
||||||
var userService = ServiceContainer.Resolve<IUserService>("userService");
|
var userService = ServiceContainer.Resolve<IUserService>("userService");
|
||||||
return userService.IsAuthenticatedAsync().GetAwaiter().GetResult();
|
return userService.IsAuthenticatedAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LaunchLoginFlow()
|
private void LaunchLoginFlow()
|
||||||
|
Loading…
Reference in New Issue
Block a user