mirror of
https://github.com/bitwarden/mobile
synced 2025-12-13 06:43:17 +00:00
log autofill events
This commit is contained in:
@@ -36,6 +36,7 @@ namespace Bit.Droid.Services
|
|||||||
private readonly IStorageService _storageService;
|
private readonly IStorageService _storageService;
|
||||||
private readonly IMessagingService _messagingService;
|
private readonly IMessagingService _messagingService;
|
||||||
private readonly IBroadcasterService _broadcasterService;
|
private readonly IBroadcasterService _broadcasterService;
|
||||||
|
private readonly IEventService _eventService;
|
||||||
private ProgressDialog _progressDialog;
|
private ProgressDialog _progressDialog;
|
||||||
private bool _cameraPermissionsDenied;
|
private bool _cameraPermissionsDenied;
|
||||||
private Toast _toast;
|
private Toast _toast;
|
||||||
@@ -43,11 +44,13 @@ namespace Bit.Droid.Services
|
|||||||
public DeviceActionService(
|
public DeviceActionService(
|
||||||
IStorageService storageService,
|
IStorageService storageService,
|
||||||
IMessagingService messagingService,
|
IMessagingService messagingService,
|
||||||
IBroadcasterService broadcasterService)
|
IBroadcasterService broadcasterService,
|
||||||
|
IEventService eventService)
|
||||||
{
|
{
|
||||||
_storageService = storageService;
|
_storageService = storageService;
|
||||||
_messagingService = messagingService;
|
_messagingService = messagingService;
|
||||||
_broadcasterService = broadcasterService;
|
_broadcasterService = broadcasterService;
|
||||||
|
_eventService = eventService;
|
||||||
|
|
||||||
_broadcasterService.Subscribe(nameof(DeviceActionService), (message) =>
|
_broadcasterService.Subscribe(nameof(DeviceActionService), (message) =>
|
||||||
{
|
{
|
||||||
@@ -463,6 +466,7 @@ namespace Bit.Droid.Services
|
|||||||
replyIntent.PutExtra(AutofillManager.ExtraAuthenticationResult, dataset);
|
replyIntent.PutExtra(AutofillManager.ExtraAuthenticationResult, dataset);
|
||||||
activity.SetResult(Result.Ok, replyIntent);
|
activity.SetResult(Result.Ok, replyIntent);
|
||||||
activity.Finish();
|
activity.Finish();
|
||||||
|
var eventTask = _eventService.CollectAsync(EventType.Cipher_ClientAutofilled, cipher.Id);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -488,6 +492,7 @@ namespace Bit.Droid.Services
|
|||||||
}
|
}
|
||||||
activity.Finish();
|
activity.Finish();
|
||||||
_messagingService.Send("finishMainActivity");
|
_messagingService.Send("finishMainActivity");
|
||||||
|
var eventTask = _eventService.CollectAsync(EventType.Cipher_ClientAutofilled, cipher.Id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -102,7 +102,8 @@ namespace Bit.iOS.Autofill
|
|||||||
CheckLock(() => PerformSegue("setupSegue", this));
|
CheckLock(() => PerformSegue("setupSegue", this));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CompleteRequest(string username = null, string password = null, string totp = null)
|
public void CompleteRequest(string id = null, string username = null,
|
||||||
|
string password = null, string totp = null)
|
||||||
{
|
{
|
||||||
ServiceContainer.Reset();
|
ServiceContainer.Reset();
|
||||||
|
|
||||||
@@ -125,6 +126,8 @@ 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(() => ExtensionContext?.CompleteRequest(cred, null));
|
||||||
}
|
}
|
||||||
@@ -207,7 +210,7 @@ namespace Bit.iOS.Autofill
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CompleteRequest(decCipher.Login.Username, decCipher.Login.Password, totpCode);
|
CompleteRequest(decCipher.Id, decCipher.Login.Username, decCipher.Login.Password, totpCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CheckLock(Action notLockedAction)
|
private void CheckLock(Action notLockedAction)
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ namespace Bit.iOS.Autofill
|
|||||||
public override UIBarButtonItem BaseCancelButton => CancelBarButton;
|
public override UIBarButtonItem BaseCancelButton => CancelBarButton;
|
||||||
public override UIBarButtonItem BaseSaveButton => SaveBarButton;
|
public override UIBarButtonItem BaseSaveButton => SaveBarButton;
|
||||||
|
|
||||||
public override Action Success => () =>
|
public override Action<string> Success => id =>
|
||||||
{
|
{
|
||||||
LoginListController?.DismissModal();
|
LoginListController?.DismissModal();
|
||||||
LoginSearchController?.DismissModal();
|
LoginSearchController?.DismissModal();
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ namespace Bit.iOS.Autofill.Utilities
|
|||||||
var item = tableSource.Items.ElementAt(indexPath.Row);
|
var item = tableSource.Items.ElementAt(indexPath.Row);
|
||||||
if(item == null)
|
if(item == null)
|
||||||
{
|
{
|
||||||
cpViewController.CompleteRequest(null);
|
cpViewController.CompleteRequest();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,7 +47,7 @@ namespace Bit.iOS.Autofill.Utilities
|
|||||||
totp = await totpService.GetCodeAsync(item.Totp);
|
totp = await totpService.GetCodeAsync(item.Totp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cpViewController.CompleteRequest(item.Username, item.Password, totp);
|
cpViewController.CompleteRequest(item.Id, item.Username, item.Password, totp);
|
||||||
}
|
}
|
||||||
else if(!string.IsNullOrWhiteSpace(item.Username) || !string.IsNullOrWhiteSpace(item.Password) ||
|
else if(!string.IsNullOrWhiteSpace(item.Username) || !string.IsNullOrWhiteSpace(item.Password) ||
|
||||||
!string.IsNullOrWhiteSpace(item.Totp))
|
!string.IsNullOrWhiteSpace(item.Totp))
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ namespace Bit.iOS.Core.Controllers
|
|||||||
public abstract UINavigationItem BaseNavItem { get; }
|
public abstract UINavigationItem BaseNavItem { get; }
|
||||||
public abstract UIBarButtonItem BaseCancelButton { get; }
|
public abstract UIBarButtonItem BaseCancelButton { get; }
|
||||||
public abstract UIBarButtonItem BaseSaveButton { get; }
|
public abstract UIBarButtonItem BaseSaveButton { get; }
|
||||||
public abstract Action Success { get; }
|
public abstract Action<string> Success { get; }
|
||||||
|
|
||||||
public override void ViewDidLoad()
|
public override void ViewDidLoad()
|
||||||
{
|
{
|
||||||
@@ -187,7 +187,7 @@ namespace Bit.iOS.Core.Controllers
|
|||||||
{
|
{
|
||||||
await ASHelpers.ReplaceAllIdentities();
|
await ASHelpers.ReplaceAllIdentities();
|
||||||
}
|
}
|
||||||
Success();
|
Success(cipherDomain.Id);
|
||||||
}
|
}
|
||||||
catch(ApiException e)
|
catch(ApiException e)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ namespace Bit.iOS.Extension
|
|||||||
{
|
{
|
||||||
var alert = Dialogs.CreateAlert(null, AppResources.MustLogInMainApp, AppResources.Ok, (a) =>
|
var alert = Dialogs.CreateAlert(null, AppResources.MustLogInMainApp, AppResources.Ok, (a) =>
|
||||||
{
|
{
|
||||||
CompleteRequest(null);
|
CompleteRequest(null, null);
|
||||||
});
|
});
|
||||||
PresentViewController(alert, true, null);
|
PresentViewController(alert, true, null);
|
||||||
return;
|
return;
|
||||||
@@ -131,7 +131,7 @@ namespace Bit.iOS.Extension
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CompleteUsernamePasswordRequest(string username, string password,
|
public void CompleteUsernamePasswordRequest(string id, string username, string password,
|
||||||
List<Tuple<string, string>> fields, string totp)
|
List<Tuple<string, string>> fields, string totp)
|
||||||
{
|
{
|
||||||
NSDictionary itemData = null;
|
NSDictionary itemData = null;
|
||||||
@@ -172,10 +172,10 @@ namespace Bit.iOS.Extension
|
|||||||
{
|
{
|
||||||
UIPasteboard.General.String = totp;
|
UIPasteboard.General.String = totp;
|
||||||
}
|
}
|
||||||
CompleteRequest(itemData);
|
CompleteRequest(id, itemData);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CompleteRequest(NSDictionary itemData)
|
public void CompleteRequest(string id, NSDictionary itemData)
|
||||||
{
|
{
|
||||||
ServiceContainer.Reset();
|
ServiceContainer.Reset();
|
||||||
|
|
||||||
@@ -183,6 +183,11 @@ namespace Bit.iOS.Extension
|
|||||||
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 };
|
||||||
|
if(!string.IsNullOrWhiteSpace(id) && itemData != null)
|
||||||
|
{
|
||||||
|
var eventService = ServiceContainer.Resolve<IEventService>("eventService");
|
||||||
|
var task = eventService.CollectAsync(Bit.Core.Enums.EventType.Cipher_ClientAutofilled, id);
|
||||||
|
}
|
||||||
NSRunLoop.Main.BeginInvokeOnMainThread(() => ExtensionContext?.CompleteRequest(returningItems, null));
|
NSRunLoop.Main.BeginInvokeOnMainThread(() => ExtensionContext?.CompleteRequest(returningItems, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ namespace Bit.iOS.Extension
|
|||||||
public override UIBarButtonItem BaseCancelButton => CancelButton;
|
public override UIBarButtonItem BaseCancelButton => CancelButton;
|
||||||
public override UIBarButtonItem BaseSubmitButton => SubmitButton;
|
public override UIBarButtonItem BaseSubmitButton => SubmitButton;
|
||||||
public override Action Success => () => LoadingController.DismissLockAndContinue();
|
public override Action Success => () => LoadingController.DismissLockAndContinue();
|
||||||
public override Action Cancel => () => LoadingController.CompleteRequest(null);
|
public override Action Cancel => () => LoadingController.CompleteRequest(null, null);
|
||||||
|
|
||||||
public override void ViewDidLoad()
|
public override void ViewDidLoad()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ namespace Bit.iOS.Extension
|
|||||||
CancelBarButton.TintColor = ThemeHelpers.NavBarTextColor;
|
CancelBarButton.TintColor = ThemeHelpers.NavBarTextColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Action Success => () =>
|
public override Action<string> Success => id =>
|
||||||
{
|
{
|
||||||
if(LoginListController != null)
|
if(LoginListController != null)
|
||||||
{
|
{
|
||||||
@@ -33,7 +33,7 @@ namespace Bit.iOS.Extension
|
|||||||
}
|
}
|
||||||
else if(LoadingController != null)
|
else if(LoadingController != null)
|
||||||
{
|
{
|
||||||
LoadingController.CompleteUsernamePasswordRequest(UsernameCell.TextField.Text,
|
LoadingController.CompleteUsernamePasswordRequest(id, UsernameCell.TextField.Text,
|
||||||
PasswordCell.TextField.Text, null, null);
|
PasswordCell.TextField.Text, null, null);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -46,7 +46,7 @@ namespace Bit.iOS.Extension
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LoadingController.CompleteRequest(null);
|
LoadingController.CompleteRequest(null, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ namespace Bit.iOS.Extension
|
|||||||
|
|
||||||
partial void CancelBarButton_Activated(UIBarButtonItem sender)
|
partial void CancelBarButton_Activated(UIBarButtonItem sender)
|
||||||
{
|
{
|
||||||
LoadingController.CompleteRequest(null);
|
LoadingController.CompleteRequest(null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
partial void AddBarButton_Activated(UIBarButtonItem sender)
|
partial void AddBarButton_Activated(UIBarButtonItem sender)
|
||||||
@@ -110,7 +110,7 @@ namespace Bit.iOS.Extension
|
|||||||
var item = Items.ElementAt(indexPath.Row);
|
var item = Items.ElementAt(indexPath.Row);
|
||||||
if(item == null)
|
if(item == null)
|
||||||
{
|
{
|
||||||
_controller.LoadingController.CompleteRequest(null);
|
_controller.LoadingController.CompleteRequest(null, null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -125,7 +125,7 @@ namespace Bit.iOS.Extension
|
|||||||
totp = GetTotpAsync(item).GetAwaiter().GetResult();
|
totp = GetTotpAsync(item).GetAwaiter().GetResult();
|
||||||
}
|
}
|
||||||
_controller.LoadingController.CompleteUsernamePasswordRequest(
|
_controller.LoadingController.CompleteUsernamePasswordRequest(
|
||||||
item.Username, item.Password, item.Fields, totp);
|
item.Id, item.Username, item.Password, item.Fields, totp);
|
||||||
}
|
}
|
||||||
else if(!string.IsNullOrWhiteSpace(item.Username) || !string.IsNullOrWhiteSpace(item.Password) ||
|
else if(!string.IsNullOrWhiteSpace(item.Username) || !string.IsNullOrWhiteSpace(item.Password) ||
|
||||||
!string.IsNullOrWhiteSpace(item.Totp))
|
!string.IsNullOrWhiteSpace(item.Totp))
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ namespace Bit.iOS.Extension
|
|||||||
|
|
||||||
partial void BackButton_Activated(UIBarButtonItem sender)
|
partial void BackButton_Activated(UIBarButtonItem sender)
|
||||||
{
|
{
|
||||||
LoadingController.CompleteRequest(null);
|
LoadingController.CompleteRequest(null, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user