public void CompleteRequest(string id       = null, string username = null,
                                    string password = null, string totp     = null)
        {
            if ((_context?.Configuring ?? true) && string.IsNullOrWhiteSpace(password))
            {
                ServiceContainer.Reset();
                ExtensionContext?.CompleteExtensionConfigurationRequest();
                return;
            }

            if (_context == null || string.IsNullOrWhiteSpace(username) || string.IsNullOrWhiteSpace(password))
            {
                ServiceContainer.Reset();
                var err = new NSError(new NSString("ASExtensionErrorDomain"),
                                      Convert.ToInt32(ASExtensionErrorCode.UserCanceled), null);
                NSRunLoop.Main.BeginInvokeOnMainThread(() => ExtensionContext?.CancelRequest(err));
                return;
            }

            if (!string.IsNullOrWhiteSpace(totp))
            {
                UIPasteboard.General.String = totp;
            }

            var cred = new ASPasswordCredential(username, password);

            NSRunLoop.Main.BeginInvokeOnMainThread(async() =>
            {
                if (!string.IsNullOrWhiteSpace(id))
                {
                    var eventService = ServiceContainer.Resolve <IEventService>("eventService");
                    await eventService.CollectAsync(Bit.Core.Enums.EventType.Cipher_ClientAutofilled, id);
                }
                ServiceContainer.Reset();
                ExtensionContext?.CompleteRequest(cred, null);
            });
        }
Exemplo n.º 2
0
 private void DidCompleteAuthWithPassword(object sender, ASPasswordCredential e)
 {
     SignInWithUserAndPassword(e);
 }
Exemplo n.º 3
0
 /// <summary>
 ///     Sign in using an existing iCloud Keychain credential.
 /// </summary>
 /// <param name="passwdCredential">A password credential.</param>
 /// <returns></returns>
 protected abstract Task SignInWithUserAndPassword(ASPasswordCredential passwdCredential);