1
0
mirror of https://github.com/bitwarden/mobile.git synced 2024-11-26 12:16:07 +01:00

* CredentialProviderViewController.cs:

* LoadingViewController.cs: reset after using event service
This commit is contained in:
kspearrin 2019-07-22 21:35:05 -04:00
parent f9547f158e
commit fe5cdb0004
2 changed files with 18 additions and 12 deletions

View File

@ -105,16 +105,16 @@ namespace Bit.iOS.Autofill
public void CompleteRequest(string id = null, string username = null, public void CompleteRequest(string id = null, string username = null,
string password = null, string totp = null) string password = null, string totp = null)
{ {
ServiceContainer.Reset();
if((_context?.Configuring ?? true) && string.IsNullOrWhiteSpace(password)) if((_context?.Configuring ?? true) && string.IsNullOrWhiteSpace(password))
{ {
ServiceContainer.Reset();
ExtensionContext?.CompleteExtensionConfigurationRequest(); ExtensionContext?.CompleteExtensionConfigurationRequest();
return; return;
} }
if(_context == null || string.IsNullOrWhiteSpace(username) || string.IsNullOrWhiteSpace(password)) if(_context == null || string.IsNullOrWhiteSpace(username) || string.IsNullOrWhiteSpace(password))
{ {
ServiceContainer.Reset();
var err = new NSError(new NSString("ASExtensionErrorDomain"), var err = new NSError(new NSString("ASExtensionErrorDomain"),
Convert.ToInt32(ASExtensionErrorCode.UserCanceled), null); Convert.ToInt32(ASExtensionErrorCode.UserCanceled), null);
NSRunLoop.Main.BeginInvokeOnMainThread(() => ExtensionContext?.CancelRequest(err)); NSRunLoop.Main.BeginInvokeOnMainThread(() => ExtensionContext?.CancelRequest(err));
@ -126,10 +126,14 @@ namespace Bit.iOS.Autofill
UIPasteboard.General.String = totp; UIPasteboard.General.String = totp;
} }
var eventService = ServiceContainer.Resolve<IEventService>("eventService");
var task = eventService.CollectAsync(Bit.Core.Enums.EventType.Cipher_ClientAutofilled, id);
var cred = new ASPasswordCredential(username, password); var cred = new ASPasswordCredential(username, password);
NSRunLoop.Main.BeginInvokeOnMainThread(() => ExtensionContext?.CompleteRequest(cred, null)); NSRunLoop.Main.BeginInvokeOnMainThread(async () =>
{
var eventService = ServiceContainer.Resolve<IEventService>("eventService");
await eventService.CollectAsync(Bit.Core.Enums.EventType.Cipher_ClientAutofilled, id);
ServiceContainer.Reset();
ExtensionContext?.CompleteRequest(cred, null);
});
} }
public override void PrepareForSegue(UIStoryboardSegue segue, NSObject sender) public override void PrepareForSegue(UIStoryboardSegue segue, NSObject sender)

View File

@ -177,18 +177,20 @@ namespace Bit.iOS.Extension
public void CompleteRequest(string id, NSDictionary itemData) public void CompleteRequest(string id, NSDictionary itemData)
{ {
ServiceContainer.Reset();
Debug.WriteLine("BW LOG, itemData: " + itemData); Debug.WriteLine("BW LOG, itemData: " + itemData);
var resultsProvider = new NSItemProvider(itemData, UTType.PropertyList); var resultsProvider = new NSItemProvider(itemData, UTType.PropertyList);
var resultsItem = new NSExtensionItem { Attachments = new NSItemProvider[] { resultsProvider } }; var resultsItem = new NSExtensionItem { Attachments = new NSItemProvider[] { resultsProvider } };
var returningItems = new NSExtensionItem[] { resultsItem }; var returningItems = new NSExtensionItem[] { resultsItem };
NSRunLoop.Main.BeginInvokeOnMainThread(async () =>
{
if (!string.IsNullOrWhiteSpace(id) && itemData != null) if (!string.IsNullOrWhiteSpace(id) && itemData != null)
{ {
var eventService = ServiceContainer.Resolve<IEventService>("eventService"); var eventService = ServiceContainer.Resolve<IEventService>("eventService");
var task = eventService.CollectAsync(Bit.Core.Enums.EventType.Cipher_ClientAutofilled, id); await eventService.CollectAsync(Bit.Core.Enums.EventType.Cipher_ClientAutofilled, id);
} }
NSRunLoop.Main.BeginInvokeOnMainThread(() => ExtensionContext?.CompleteRequest(returningItems, null)); ServiceContainer.Reset();
ExtensionContext?.CompleteRequest(returningItems, null);
});
} }
private bool ProcessItemProvider(NSItemProvider itemProvider, string type, Action<NSDictionary> dictAction, private bool ProcessItemProvider(NSItemProvider itemProvider, string type, Action<NSDictionary> dictAction,