From 5ce2eaf77e0f7ded46f99c6fe92a8bc9223bdbf5 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Sat, 1 Jun 2019 01:07:02 -0400 Subject: [PATCH] dont auto show fingerprint if lock is initiated --- src/App/App.xaml.cs | 3 ++- src/App/Pages/Accounts/LockPage.xaml.cs | 6 ++++-- src/App/Pages/Accounts/LockPageViewModel.cs | 13 ++++++++----- .../Settings/SettingsPage/SettingsPageViewModel.cs | 2 +- .../Pages/Vault/GroupingsPage/GroupingsPage.xaml.cs | 12 ++++++------ src/Core/Abstractions/ILockService.cs | 2 +- src/Core/Services/LockService.cs | 6 +++--- 7 files changed, 25 insertions(+), 19 deletions(-) diff --git a/src/App/App.xaml.cs b/src/App/App.xaml.cs index 8ec206f8e..3905c3313 100644 --- a/src/App/App.xaml.cs +++ b/src/App/App.xaml.cs @@ -90,7 +90,8 @@ namespace Bit.App else if(message.Command == "locked") { await _stateService.PurgeAsync(); - Device.BeginInvokeOnMainThread(() => Current.MainPage = new NavigationPage(new LockPage())); + var lockPage = new LockPage(null, !(message.Data as bool?).GetValueOrDefault()); + Device.BeginInvokeOnMainThread(() => Current.MainPage = new NavigationPage(lockPage)); } else if(message.Command == "lockVault") { diff --git a/src/App/Pages/Accounts/LockPage.xaml.cs b/src/App/Pages/Accounts/LockPage.xaml.cs index 41714ec94..2950d6352 100644 --- a/src/App/Pages/Accounts/LockPage.xaml.cs +++ b/src/App/Pages/Accounts/LockPage.xaml.cs @@ -8,11 +8,13 @@ namespace Bit.App.Pages public partial class LockPage : BaseContentPage { private readonly AppOptions _appOptions; + private readonly bool _autoPromptFingerprint; private readonly LockPageViewModel _vm; - public LockPage(AppOptions appOptions = null) + public LockPage(AppOptions appOptions = null, bool autoPromptFingerprint = true) { _appOptions = appOptions; + _autoPromptFingerprint = autoPromptFingerprint; InitializeComponent(); _vm = BindingContext as LockPageViewModel; _vm.Page = this; @@ -43,7 +45,7 @@ namespace Bit.App.Pages protected override async void OnAppearing() { base.OnAppearing(); - await _vm.InitAsync(); + await _vm.InitAsync(_autoPromptFingerprint); if(!_vm.FingerprintLock) { if(_vm.PinLock) diff --git a/src/App/Pages/Accounts/LockPageViewModel.cs b/src/App/Pages/Accounts/LockPageViewModel.cs index f54ae9631..5242e69de 100644 --- a/src/App/Pages/Accounts/LockPageViewModel.cs +++ b/src/App/Pages/Accounts/LockPageViewModel.cs @@ -97,7 +97,7 @@ namespace Bit.App.Pages public string Pin { get; set; } public Action UnlockedAction { get; set; } - public async Task InitAsync() + public async Task InitAsync(bool autoPromptFingerprint) { _pinSet = await _lockService.IsPinLockSetAsync(); _hasKey = await _cryptoService.HasKeyAsync(); @@ -120,11 +120,14 @@ namespace Bit.App.Pages { FingerprintButtonText = _deviceActionService.SupportsFaceId() ? AppResources.UseFaceIDToUnlock : AppResources.UseFingerprintToUnlock; - var tasks = Task.Run(async () => + if(autoPromptFingerprint) { - await Task.Delay(500); - Device.BeginInvokeOnMainThread(async () => await PromptFingerprintAsync()); - }); + var tasks = Task.Run(async () => + { + await Task.Delay(500); + Device.BeginInvokeOnMainThread(async () => await PromptFingerprintAsync()); + }); + } } } diff --git a/src/App/Pages/Settings/SettingsPage/SettingsPageViewModel.cs b/src/App/Pages/Settings/SettingsPage/SettingsPageViewModel.cs index 138636c83..4657a7e16 100644 --- a/src/App/Pages/Settings/SettingsPage/SettingsPageViewModel.cs +++ b/src/App/Pages/Settings/SettingsPage/SettingsPageViewModel.cs @@ -182,7 +182,7 @@ namespace Bit.App.Pages public async Task LockAsync() { - await _lockService.LockAsync(true); + await _lockService.LockAsync(true, true); } public async Task LockOptionsAsync() diff --git a/src/App/Pages/Vault/GroupingsPage/GroupingsPage.xaml.cs b/src/App/Pages/Vault/GroupingsPage/GroupingsPage.xaml.cs index b29adf34b..09999fb61 100644 --- a/src/App/Pages/Vault/GroupingsPage/GroupingsPage.xaml.cs +++ b/src/App/Pages/Vault/GroupingsPage/GroupingsPage.xaml.cs @@ -147,7 +147,7 @@ namespace Bit.App.Pages } } - private async void Search_Clicked(object sender, System.EventArgs e) + private async void Search_Clicked(object sender, EventArgs e) { if(DoOnce()) { @@ -157,22 +157,22 @@ namespace Bit.App.Pages } } - private async void Sync_Clicked(object sender, System.EventArgs e) + private async void Sync_Clicked(object sender, EventArgs e) { await _vm.SyncAsync(); } - private async void Lock_Clicked(object sender, System.EventArgs e) + private async void Lock_Clicked(object sender, EventArgs e) { - await _lockService.LockAsync(true); + await _lockService.LockAsync(true, true); } - private async void Exit_Clicked(object sender, System.EventArgs e) + private async void Exit_Clicked(object sender, EventArgs e) { await _vm.ExitAsync(); } - private async void AddButton_Clicked(object sender, System.EventArgs e) + private async void AddButton_Clicked(object sender, EventArgs e) { if(DoOnce()) { diff --git a/src/Core/Abstractions/ILockService.cs b/src/Core/Abstractions/ILockService.cs index d6c167f85..43e7b0270 100644 --- a/src/Core/Abstractions/ILockService.cs +++ b/src/Core/Abstractions/ILockService.cs @@ -13,7 +13,7 @@ namespace Bit.Core.Abstractions Task IsLockedAsync(); Task> IsPinLockSetAsync(); Task IsFingerprintLockSetAsync(); - Task LockAsync(bool allowSoftLock = false); + Task LockAsync(bool allowSoftLock = false, bool userInitiated = false); Task SetLockOptionAsync(int? lockOption); } } \ No newline at end of file diff --git a/src/Core/Services/LockService.cs b/src/Core/Services/LockService.cs index a8b013ea7..41b9ab974 100644 --- a/src/Core/Services/LockService.cs +++ b/src/Core/Services/LockService.cs @@ -99,7 +99,7 @@ namespace Bit.Core.Services } } - public async Task LockAsync(bool allowSoftLock = false) + public async Task LockAsync(bool allowSoftLock = false, bool userInitiated = false) { var authed = await _userService.IsAuthenticatedAsync(); if(!authed) @@ -119,7 +119,7 @@ namespace Bit.Core.Services } if(FingerprintLocked || PinLocked) { - _messagingService.Send("locked"); + _messagingService.Send("locked", userInitiated); // TODO: locked callback? return; } @@ -134,7 +134,7 @@ namespace Bit.Core.Services _cipherService.ClearCache(); _collectionService.ClearCache(); _searchService.ClearIndex(); - _messagingService.Send("locked"); + _messagingService.Send("locked", userInitiated); // TODO: locked callback? }