From c043528a160ea128d8415433c52e84d564cf34dc Mon Sep 17 00:00:00 2001 From: Matt Portune <59324545+mportune-bw@users.noreply.github.com> Date: Tue, 8 Mar 2022 14:26:35 -0500 Subject: [PATCH] fix for lock & logout message parsing issue (#1832) --- src/App/App.xaml.cs | 11 +++++++---- src/Core/Services/VaultTimeoutService.cs | 14 +++++++------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/App/App.xaml.cs b/src/App/App.xaml.cs index a7e35f3ab..50ce388b6 100644 --- a/src/App/App.xaml.cs +++ b/src/App/App.xaml.cs @@ -73,8 +73,9 @@ namespace Bit.App } else if (message.Command == "locked") { - var (userId, userInitiated) = - message.Data as Tuple ?? new Tuple(null, false); + var extras = message.Data as Tuple; + var userId = extras?.Item1; + var userInitiated = extras?.Item2 ?? false; Device.BeginInvokeOnMainThread(async () => await LockedAsync(userId, userInitiated)); } else if (message.Command == "lockVault") @@ -83,8 +84,10 @@ namespace Bit.App } else if (message.Command == "logout") { - var (userId, userInitiated, expired) = - message.Data as Tuple ?? new Tuple(null, true, false); + var extras = message.Data as Tuple; + var userId = extras?.Item1; + var userInitiated = extras?.Item2 ?? true; + var expired = extras?.Item3 ?? false; Device.BeginInvokeOnMainThread(async () => await LogOutAsync(userId, userInitiated, expired)); } else if (message.Command == "loggedOut") diff --git a/src/Core/Services/VaultTimeoutService.cs b/src/Core/Services/VaultTimeoutService.cs index d602ec260..df298ed8d 100644 --- a/src/Core/Services/VaultTimeoutService.cs +++ b/src/Core/Services/VaultTimeoutService.cs @@ -19,8 +19,8 @@ namespace Bit.Core.Services private readonly ITokenService _tokenService; private readonly IPolicyService _policyService; private readonly IKeyConnectorService _keyConnectorService; - private readonly Func<(string userId, bool userInitiated), Task> _lockedCallback; - private readonly Func<(string userId, bool userInitiated, bool expired), Task> _loggedOutCallback; + private readonly Func, Task> _lockedCallback; + private readonly Func, Task> _loggedOutCallback; public VaultTimeoutService( ICryptoService cryptoService, @@ -34,8 +34,8 @@ namespace Bit.Core.Services ITokenService tokenService, IPolicyService policyService, IKeyConnectorService keyConnectorService, - Func<(string userId, bool userInitiated), Task> lockedCallback, - Func<(string userId, bool userInitiated, bool expired), Task> loggedOutCallback) + Func, Task> lockedCallback, + Func, Task> loggedOutCallback) { _cryptoService = cryptoService; _stateService = stateService; @@ -183,7 +183,7 @@ namespace Bit.Core.Services await _stateService.SetBiometricLockedAsync(isBiometricLockSet, userId); if (isBiometricLockSet) { - _lockedCallback?.Invoke((userId, userInitiated)); + _lockedCallback?.Invoke(new Tuple(userId, userInitiated)); return; } } @@ -200,14 +200,14 @@ namespace Bit.Core.Services _collectionService.ClearCache(); _searchService.ClearIndex(); } - _lockedCallback?.Invoke((userId, userInitiated)); + _lockedCallback?.Invoke(new Tuple(userId, userInitiated)); } public async Task LogOutAsync(bool userInitiated = true, string userId = null) { if(_loggedOutCallback != null) { - await _loggedOutCallback.Invoke((userId, userInitiated, false)); + await _loggedOutCallback.Invoke(new Tuple(userId, userInitiated, false)); } }