mirror of
https://github.com/bitwarden/android.git
synced 2024-10-31 15:15:34 +03:00
fix for lock & logout message parsing issue (#1832)
This commit is contained in:
parent
fd74164f82
commit
c043528a16
2 changed files with 14 additions and 11 deletions
|
@ -73,8 +73,9 @@ namespace Bit.App
|
||||||
}
|
}
|
||||||
else if (message.Command == "locked")
|
else if (message.Command == "locked")
|
||||||
{
|
{
|
||||||
var (userId, userInitiated) =
|
var extras = message.Data as Tuple<string, bool>;
|
||||||
message.Data as Tuple<string, bool> ?? new Tuple<string, bool>(null, false);
|
var userId = extras?.Item1;
|
||||||
|
var userInitiated = extras?.Item2 ?? false;
|
||||||
Device.BeginInvokeOnMainThread(async () => await LockedAsync(userId, userInitiated));
|
Device.BeginInvokeOnMainThread(async () => await LockedAsync(userId, userInitiated));
|
||||||
}
|
}
|
||||||
else if (message.Command == "lockVault")
|
else if (message.Command == "lockVault")
|
||||||
|
@ -83,8 +84,10 @@ namespace Bit.App
|
||||||
}
|
}
|
||||||
else if (message.Command == "logout")
|
else if (message.Command == "logout")
|
||||||
{
|
{
|
||||||
var (userId, userInitiated, expired) =
|
var extras = message.Data as Tuple<string, bool, bool>;
|
||||||
message.Data as Tuple<string, bool, bool> ?? new Tuple<string, bool, bool>(null, true, false);
|
var userId = extras?.Item1;
|
||||||
|
var userInitiated = extras?.Item2 ?? true;
|
||||||
|
var expired = extras?.Item3 ?? false;
|
||||||
Device.BeginInvokeOnMainThread(async () => await LogOutAsync(userId, userInitiated, expired));
|
Device.BeginInvokeOnMainThread(async () => await LogOutAsync(userId, userInitiated, expired));
|
||||||
}
|
}
|
||||||
else if (message.Command == "loggedOut")
|
else if (message.Command == "loggedOut")
|
||||||
|
|
|
@ -19,8 +19,8 @@ namespace Bit.Core.Services
|
||||||
private readonly ITokenService _tokenService;
|
private readonly ITokenService _tokenService;
|
||||||
private readonly IPolicyService _policyService;
|
private readonly IPolicyService _policyService;
|
||||||
private readonly IKeyConnectorService _keyConnectorService;
|
private readonly IKeyConnectorService _keyConnectorService;
|
||||||
private readonly Func<(string userId, bool userInitiated), Task> _lockedCallback;
|
private readonly Func<Tuple<string, bool>, Task> _lockedCallback;
|
||||||
private readonly Func<(string userId, bool userInitiated, bool expired), Task> _loggedOutCallback;
|
private readonly Func<Tuple<string, bool, bool>, Task> _loggedOutCallback;
|
||||||
|
|
||||||
public VaultTimeoutService(
|
public VaultTimeoutService(
|
||||||
ICryptoService cryptoService,
|
ICryptoService cryptoService,
|
||||||
|
@ -34,8 +34,8 @@ namespace Bit.Core.Services
|
||||||
ITokenService tokenService,
|
ITokenService tokenService,
|
||||||
IPolicyService policyService,
|
IPolicyService policyService,
|
||||||
IKeyConnectorService keyConnectorService,
|
IKeyConnectorService keyConnectorService,
|
||||||
Func<(string userId, bool userInitiated), Task> lockedCallback,
|
Func<Tuple<string, bool>, Task> lockedCallback,
|
||||||
Func<(string userId, bool userInitiated, bool expired), Task> loggedOutCallback)
|
Func<Tuple<string, bool, bool>, Task> loggedOutCallback)
|
||||||
{
|
{
|
||||||
_cryptoService = cryptoService;
|
_cryptoService = cryptoService;
|
||||||
_stateService = stateService;
|
_stateService = stateService;
|
||||||
|
@ -183,7 +183,7 @@ namespace Bit.Core.Services
|
||||||
await _stateService.SetBiometricLockedAsync(isBiometricLockSet, userId);
|
await _stateService.SetBiometricLockedAsync(isBiometricLockSet, userId);
|
||||||
if (isBiometricLockSet)
|
if (isBiometricLockSet)
|
||||||
{
|
{
|
||||||
_lockedCallback?.Invoke((userId, userInitiated));
|
_lockedCallback?.Invoke(new Tuple<string, bool>(userId, userInitiated));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -200,14 +200,14 @@ namespace Bit.Core.Services
|
||||||
_collectionService.ClearCache();
|
_collectionService.ClearCache();
|
||||||
_searchService.ClearIndex();
|
_searchService.ClearIndex();
|
||||||
}
|
}
|
||||||
_lockedCallback?.Invoke((userId, userInitiated));
|
_lockedCallback?.Invoke(new Tuple<string, bool>(userId, userInitiated));
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task LogOutAsync(bool userInitiated = true, string userId = null)
|
public async Task LogOutAsync(bool userInitiated = true, string userId = null)
|
||||||
{
|
{
|
||||||
if(_loggedOutCallback != null)
|
if(_loggedOutCallback != null)
|
||||||
{
|
{
|
||||||
await _loggedOutCallback.Invoke((userId, userInitiated, false));
|
await _loggedOutCallback.Invoke(new Tuple<string, bool, bool>(userId, userInitiated, false));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue