From 13b9e016047fcec73c9882b0fd5a35568b615b9e Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Mon, 16 Jul 2018 23:14:45 -0400 Subject: [PATCH] check lock only if locked on all pages --- src/App/Abstractions/Services/ILockService.cs | 4 ++-- src/App/Controls/ExtendedContentPage.cs | 3 ++- src/App/Services/LockService.cs | 11 ++++++++--- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/App/Abstractions/Services/ILockService.cs b/src/App/Abstractions/Services/ILockService.cs index 160e65f31..3d48efe7a 100644 --- a/src/App/Abstractions/Services/ILockService.cs +++ b/src/App/Abstractions/Services/ILockService.cs @@ -7,8 +7,8 @@ namespace Bit.App.Abstractions public interface ILockService { void UpdateLastActivity(); - Task GetLockTypeAsync(bool forceLock); - Task CheckLockAsync(bool forceLock); + Task GetLockTypeAsync(bool forceLock, bool onlyIfAlreadyLocked = false); + Task CheckLockAsync(bool forceLock, bool onlyIfAlreadyLocked = false); bool TopPageIsLock(); } } \ No newline at end of file diff --git a/src/App/Controls/ExtendedContentPage.cs b/src/App/Controls/ExtendedContentPage.cs index 8c591d921..527513ccd 100644 --- a/src/App/Controls/ExtendedContentPage.cs +++ b/src/App/Controls/ExtendedContentPage.cs @@ -30,7 +30,7 @@ namespace Bit.App.Controls BackgroundColor = Color.FromHex("efeff4"); } - protected override void OnAppearing() + protected async override void OnAppearing() { if(_requireAuth && !_authService.IsAuthenticated) { @@ -52,6 +52,7 @@ namespace Bit.App.Controls } _googleAnalyticsService.TrackPage(GetType().Name); + await _lockService.CheckLockAsync(false, true); base.OnAppearing(); } diff --git a/src/App/Services/LockService.cs b/src/App/Services/LockService.cs index b4a8dc3c6..8002dfc75 100644 --- a/src/App/Services/LockService.cs +++ b/src/App/Services/LockService.cs @@ -37,7 +37,7 @@ namespace Bit.App.Services _stopwatch?.Restart(); } - public async Task GetLockTypeAsync(bool forceLock) + public async Task GetLockTypeAsync(bool forceLock, bool onlyIfAlreadyLocked = false) { // Only lock if they are logged in if(!_authService.IsAuthenticated) @@ -59,6 +59,11 @@ namespace Bit.App.Services } } + if(onlyIfAlreadyLocked && !_appSettings.Locked) + { + return LockType.None; + } + // What method are we using to unlock? var fingerprintUnlock = _settings.GetValueOrDefault(Constants.SettingFingerprintUnlockOn, false); var pinUnlock = _settings.GetValueOrDefault(Constants.SettingPinUnlockOn, false); @@ -77,14 +82,14 @@ namespace Bit.App.Services } } - public async Task CheckLockAsync(bool forceLock) + public async Task CheckLockAsync(bool forceLock, bool onlyIfAlreadyLocked = false) { if(TopPageIsLock()) { return; } - var lockType = await GetLockTypeAsync(forceLock); + var lockType = await GetLockTypeAsync(forceLock, onlyIfAlreadyLocked); if(lockType == LockType.None) { return;