take environment into account when checking for existing account (#1808)

This commit is contained in:
Matt Portune 2022-02-23 15:30:49 -05:00 committed by GitHub
parent 2e8824ce05
commit 9201da8515
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 7 deletions

View File

@ -141,15 +141,12 @@ namespace Bit.App.Pages
var userId = await _stateService.GetUserIdAsync(Email);
if (!string.IsNullOrWhiteSpace(userId))
{
var switchToAccount = await _platformUtilsService.ShowDialogAsync(
AppResources.SwitchToAlreadyAddedAccountConfirmation,
AppResources.AccountAlreadyAdded, AppResources.Yes, AppResources.Cancel);
if (switchToAccount)
var userEnvUrls = await _stateService.GetEnvironmentUrlsAsync(userId);
if (userEnvUrls?.Base == _environmentService.BaseUrl)
{
await _stateService.SetActiveUserAsync(userId);
_messagingService.Send("switchedAccount");
await PromptToSwitchToExistingAccountAsync(userId);
return;
}
return;
}
}
@ -229,5 +226,17 @@ namespace Bit.App.Pages
#endif
}
}
private async Task PromptToSwitchToExistingAccountAsync(string userId)
{
var switchToAccount = await _platformUtilsService.ShowDialogAsync(
AppResources.SwitchToAlreadyAddedAccountConfirmation,
AppResources.AccountAlreadyAdded, AppResources.Yes, AppResources.Cancel);
if (switchToAccount)
{
await _stateService.SetActiveUserAsync(userId);
_messagingService.Send("switchedAccount");
}
}
}
}