dont auto show fingerprint if lock is initiated

This commit is contained in:
Kyle Spearrin 2019-06-01 01:07:02 -04:00
parent 4ae02c27a4
commit 5ce2eaf77e
7 changed files with 25 additions and 19 deletions

View file

@ -90,7 +90,8 @@ namespace Bit.App
else if(message.Command == "locked") else if(message.Command == "locked")
{ {
await _stateService.PurgeAsync(); 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") else if(message.Command == "lockVault")
{ {

View file

@ -8,11 +8,13 @@ namespace Bit.App.Pages
public partial class LockPage : BaseContentPage public partial class LockPage : BaseContentPage
{ {
private readonly AppOptions _appOptions; private readonly AppOptions _appOptions;
private readonly bool _autoPromptFingerprint;
private readonly LockPageViewModel _vm; private readonly LockPageViewModel _vm;
public LockPage(AppOptions appOptions = null) public LockPage(AppOptions appOptions = null, bool autoPromptFingerprint = true)
{ {
_appOptions = appOptions; _appOptions = appOptions;
_autoPromptFingerprint = autoPromptFingerprint;
InitializeComponent(); InitializeComponent();
_vm = BindingContext as LockPageViewModel; _vm = BindingContext as LockPageViewModel;
_vm.Page = this; _vm.Page = this;
@ -43,7 +45,7 @@ namespace Bit.App.Pages
protected override async void OnAppearing() protected override async void OnAppearing()
{ {
base.OnAppearing(); base.OnAppearing();
await _vm.InitAsync(); await _vm.InitAsync(_autoPromptFingerprint);
if(!_vm.FingerprintLock) if(!_vm.FingerprintLock)
{ {
if(_vm.PinLock) if(_vm.PinLock)

View file

@ -97,7 +97,7 @@ namespace Bit.App.Pages
public string Pin { get; set; } public string Pin { get; set; }
public Action UnlockedAction { get; set; } public Action UnlockedAction { get; set; }
public async Task InitAsync() public async Task InitAsync(bool autoPromptFingerprint)
{ {
_pinSet = await _lockService.IsPinLockSetAsync(); _pinSet = await _lockService.IsPinLockSetAsync();
_hasKey = await _cryptoService.HasKeyAsync(); _hasKey = await _cryptoService.HasKeyAsync();
@ -120,6 +120,8 @@ namespace Bit.App.Pages
{ {
FingerprintButtonText = _deviceActionService.SupportsFaceId() ? AppResources.UseFaceIDToUnlock : FingerprintButtonText = _deviceActionService.SupportsFaceId() ? AppResources.UseFaceIDToUnlock :
AppResources.UseFingerprintToUnlock; AppResources.UseFingerprintToUnlock;
if(autoPromptFingerprint)
{
var tasks = Task.Run(async () => var tasks = Task.Run(async () =>
{ {
await Task.Delay(500); await Task.Delay(500);
@ -127,6 +129,7 @@ namespace Bit.App.Pages
}); });
} }
} }
}
public async Task SubmitAsync() public async Task SubmitAsync()
{ {

View file

@ -182,7 +182,7 @@ namespace Bit.App.Pages
public async Task LockAsync() public async Task LockAsync()
{ {
await _lockService.LockAsync(true); await _lockService.LockAsync(true, true);
} }
public async Task LockOptionsAsync() public async Task LockOptionsAsync()

View file

@ -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()) 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(); 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(); await _vm.ExitAsync();
} }
private async void AddButton_Clicked(object sender, System.EventArgs e) private async void AddButton_Clicked(object sender, EventArgs e)
{ {
if(DoOnce()) if(DoOnce())
{ {

View file

@ -13,7 +13,7 @@ namespace Bit.Core.Abstractions
Task<bool> IsLockedAsync(); Task<bool> IsLockedAsync();
Task<Tuple<bool, bool>> IsPinLockSetAsync(); Task<Tuple<bool, bool>> IsPinLockSetAsync();
Task<bool> IsFingerprintLockSetAsync(); Task<bool> IsFingerprintLockSetAsync();
Task LockAsync(bool allowSoftLock = false); Task LockAsync(bool allowSoftLock = false, bool userInitiated = false);
Task SetLockOptionAsync(int? lockOption); Task SetLockOptionAsync(int? lockOption);
} }
} }

View file

@ -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(); var authed = await _userService.IsAuthenticatedAsync();
if(!authed) if(!authed)
@ -119,7 +119,7 @@ namespace Bit.Core.Services
} }
if(FingerprintLocked || PinLocked) if(FingerprintLocked || PinLocked)
{ {
_messagingService.Send("locked"); _messagingService.Send("locked", userInitiated);
// TODO: locked callback? // TODO: locked callback?
return; return;
} }
@ -134,7 +134,7 @@ namespace Bit.Core.Services
_cipherService.ClearCache(); _cipherService.ClearCache();
_collectionService.ClearCache(); _collectionService.ClearCache();
_searchService.ClearIndex(); _searchService.ClearIndex();
_messagingService.Send("locked"); _messagingService.Send("locked", userInitiated);
// TODO: locked callback? // TODO: locked callback?
} }