From 726db336a83ff4b2de32ee13f94e8f24d52e2247 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Sun, 7 Oct 2018 07:40:44 -0400 Subject: [PATCH] dont try to fill unless has username and password --- .../CredentialProviderViewController.cs | 2 +- src/iOS.Autofill/Utilities/AutofillHelpers.cs | 19 +++++++++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/iOS.Autofill/CredentialProviderViewController.cs b/src/iOS.Autofill/CredentialProviderViewController.cs index 4a3f42767..d3fc3b6ae 100644 --- a/src/iOS.Autofill/CredentialProviderViewController.cs +++ b/src/iOS.Autofill/CredentialProviderViewController.cs @@ -147,7 +147,7 @@ namespace Bit.iOS.Autofill return; } - if(_context == null || string.IsNullOrWhiteSpace(password)) + if(_context == null || string.IsNullOrWhiteSpace(username) || string.IsNullOrWhiteSpace(password)) { _googleAnalyticsService.TrackAutofillExtensionEvent("Canceled"); var err = new NSError(new NSString("ASExtensionErrorDomain"), diff --git a/src/iOS.Autofill/Utilities/AutofillHelpers.cs b/src/iOS.Autofill/Utilities/AutofillHelpers.cs index a56964841..b82bcc101 100644 --- a/src/iOS.Autofill/Utilities/AutofillHelpers.cs +++ b/src/iOS.Autofill/Utilities/AutofillHelpers.cs @@ -31,7 +31,7 @@ namespace Bit.iOS.Autofill.Utilities return; } - if(!string.IsNullOrWhiteSpace(item.Password)) + if(!string.IsNullOrWhiteSpace(item.Username) && !string.IsNullOrWhiteSpace(item.Password)) { string totp = null; if(!settings.GetValueOrDefault(App.Constants.SettingDisableTotpCopy, false)) @@ -41,7 +41,8 @@ namespace Bit.iOS.Autofill.Utilities cpViewController.CompleteRequest(item.Username, item.Password, totp); } - else if(!string.IsNullOrWhiteSpace(item.Username) || !string.IsNullOrWhiteSpace(item.Totp.Value)) + else if(!string.IsNullOrWhiteSpace(item.Username) || !string.IsNullOrWhiteSpace(item.Password) || + !string.IsNullOrWhiteSpace(item.Totp.Value)) { var sheet = Dialogs.CreateActionSheet(item.Name, controller); if(!string.IsNullOrWhiteSpace(item.Username)) @@ -58,6 +59,20 @@ namespace Bit.iOS.Autofill.Utilities })); } + if(!string.IsNullOrWhiteSpace(item.Password)) + { + sheet.AddAction(UIAlertAction.Create(AppResources.CopyPassword, UIAlertActionStyle.Default, a => + { + UIPasteboard clipboard = UIPasteboard.General; + clipboard.String = item.Password; + var alert = Dialogs.CreateMessageAlert(AppResources.CopiedPassword); + controller.PresentViewController(alert, true, () => + { + controller.DismissViewController(true, null); + }); + })); + } + if(!string.IsNullOrWhiteSpace(item.Totp.Value)) { sheet.AddAction(UIAlertAction.Create(AppResources.CopyTotp, UIAlertActionStyle.Default, a =>