1
0
mirror of https://github.com/bitwarden/mobile synced 2026-01-04 01:23:15 +00:00

fix for logging out active account from switcher and cleanup (#1830)

This commit is contained in:
Matt Portune
2022-03-07 15:15:21 -05:00
committed by GitHub
parent fcc94d85af
commit 17cdc96352
6 changed files with 38 additions and 42 deletions

View File

@@ -73,11 +73,9 @@ namespace Bit.App
}
else if (message.Command == "locked")
{
var extras = message.Data as Tuple<string, bool>;
var userId = extras?.Item1;
var userInitiated = extras?.Item2;
Device.BeginInvokeOnMainThread(async () =>
await LockedAsync(userId, userInitiated.GetValueOrDefault()));
var (userId, userInitiated) =
message.Data as Tuple<string, bool> ?? new Tuple<string, bool>(null, false);
Device.BeginInvokeOnMainThread(async () => await LockedAsync(userId, userInitiated));
}
else if (message.Command == "lockVault")
{
@@ -85,12 +83,9 @@ namespace Bit.App
}
else if (message.Command == "logout")
{
var extras = message.Data as Tuple<string, bool, bool>;
var userId = extras?.Item1;
var userInitiated = extras?.Item2;
var expired = extras?.Item3;
Device.BeginInvokeOnMainThread(async () =>
await LogOutAsync(userId, userInitiated, expired));
var (userId, userInitiated, expired) =
message.Data as Tuple<string, bool, bool> ?? new Tuple<string, bool, bool>(null, true, false);
Device.BeginInvokeOnMainThread(async () => await LogOutAsync(userId, userInitiated, expired));
}
else if (message.Command == "loggedOut")
{
@@ -262,13 +257,13 @@ namespace Bit.App
new System.Globalization.UmAlQuraCalendar();
}
private async Task LogOutAsync(string userId, bool? userInitiated, bool? expired)
private async Task LogOutAsync(string userId, bool userInitiated, bool expired)
{
await AppHelpers.LogOutAsync(userId, userInitiated.GetValueOrDefault(true));
await AppHelpers.LogOutAsync(userId, userInitiated);
await SetMainPageAsync();
_authService.LogOut(() =>
{
if (expired.GetValueOrDefault())
if (expired)
{
_platformUtilsService.ShowToast("warning", null, AppResources.LoginExpired);
}
@@ -432,7 +427,7 @@ namespace Bit.App
private async Task LockedAsync(string userId, bool autoPromptBiometric)
{
if (!await _stateService.IsActiveAccount(userId))
if (!await _stateService.IsActiveAccountAsync(userId))
{
_platformUtilsService.ShowToast("info", null, AppResources.AccountLockedSuccessfully);
return;

View File

@@ -240,6 +240,13 @@ namespace Bit.App.Utilities
await platformUtilsService.ShowDialogAsync(text, title, AppResources.Yes, AppResources.Cancel);
if (confirmed)
{
var stateService = ServiceContainer.Resolve<IStateService>("stateService");
if (await stateService.IsActiveAccountAsync(userId))
{
var messagingService = ServiceContainer.Resolve<IMessagingService>("messagingService");
messagingService.Send("logout");
return selection;
}
await LogOutAsync(userId, true);
}
}
@@ -509,7 +516,7 @@ namespace Bit.App.Utilities
var policyService = ServiceContainer.Resolve<IPolicyService>("policyService");
var searchService = ServiceContainer.Resolve<ISearchService>("searchService");
var isActiveAccount = await stateService.IsActiveAccount(userId);
var isActiveAccount = await stateService.IsActiveAccountAsync(userId);
if (userId == null)
{