From bc949fe87ae4ce8c56e58e5f42aca6e287db94dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Bispo?= Date: Mon, 3 Oct 2022 17:11:38 +0100 Subject: [PATCH] [SG-691] Login request is not displayed after changing accounts (#2111) * [SG-691] Added new message to be broadcasted when account is switched to trigger a check for login requests. * [SG-691] PR fixes --- src/Android/MainApplication.cs | 5 +++-- src/App/App.xaml.cs | 2 +- src/App/Utilities/AccountManagement/AccountsManager.cs | 7 +++++-- src/Core/Utilities/AccountsManagerMessageCommands.cs | 1 + src/iOS.Core/Utilities/iOSCoreHelpers.cs | 3 ++- 5 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/Android/MainApplication.cs b/src/Android/MainApplication.cs index 5abef72b3..3388b2ea7 100644 --- a/src/Android/MainApplication.cs +++ b/src/Android/MainApplication.cs @@ -72,8 +72,9 @@ namespace Bit.Droid ServiceContainer.Resolve("stateService"), ServiceContainer.Resolve("platformUtilsService"), ServiceContainer.Resolve("authService"), - ServiceContainer.Resolve("logger")); - ServiceContainer.Register("accountsManager", accountsManager); + ServiceContainer.Resolve("logger"), + ServiceContainer.Resolve("messagingService")); + ServiceContainer.Register("accountsManager", accountsManager); } #if !FDROID if (Build.VERSION.SdkInt <= BuildVersionCodes.Kitkat) diff --git a/src/App/App.xaml.cs b/src/App/App.xaml.cs index 35c22126c..1223b842b 100644 --- a/src/App/App.xaml.cs +++ b/src/App/App.xaml.cs @@ -140,7 +140,7 @@ namespace Bit.App new NavigationPage(new RemoveMasterPasswordPage())); }); } - else if (message.Command == "passwordlessLoginRequest" || message.Command == "unlocked") + else if (message.Command == "passwordlessLoginRequest" || message.Command == "unlocked" || message.Command == AccountsManagerMessageCommands.ACCOUNT_SWITCH_COMPLETED) { CheckPasswordlessLoginRequestsAsync().FireAndForget(); } diff --git a/src/App/Utilities/AccountManagement/AccountsManager.cs b/src/App/Utilities/AccountManagement/AccountsManager.cs index 88701f2b7..bf64901c9 100644 --- a/src/App/Utilities/AccountManagement/AccountsManager.cs +++ b/src/App/Utilities/AccountManagement/AccountsManager.cs @@ -20,7 +20,7 @@ namespace Bit.App.Utilities.AccountManagement private readonly IPlatformUtilsService _platformUtilsService; private readonly IAuthService _authService; private readonly ILogger _logger; - + private readonly IMessagingService _messagingService; Func _getOptionsFunc; private IAccountsManagerHost _accountsManagerHost; @@ -30,7 +30,8 @@ namespace Bit.App.Utilities.AccountManagement IStateService stateService, IPlatformUtilsService platformUtilsService, IAuthService authService, - ILogger logger) + ILogger logger, + IMessagingService messagingService) { _broadcasterService = broadcasterService; _vaultTimeoutService = vaultTimeoutService; @@ -39,6 +40,7 @@ namespace Bit.App.Utilities.AccountManagement _platformUtilsService = platformUtilsService; _authService = authService; _logger = logger; + _messagingService = messagingService; } private AppOptions Options => _getOptionsFunc?.Invoke() ?? new AppOptions { IosExtension = true }; @@ -213,6 +215,7 @@ namespace Bit.App.Utilities.AccountManagement } await Task.Delay(50); await _accountsManagerHost.UpdateThemeAsync(); + _messagingService.Send(AccountsManagerMessageCommands.ACCOUNT_SWITCH_COMPLETED); }); } } diff --git a/src/Core/Utilities/AccountsManagerMessageCommands.cs b/src/Core/Utilities/AccountsManagerMessageCommands.cs index bdd80a867..c5af40e78 100644 --- a/src/Core/Utilities/AccountsManagerMessageCommands.cs +++ b/src/Core/Utilities/AccountsManagerMessageCommands.cs @@ -9,5 +9,6 @@ public const string ADD_ACCOUNT = "addAccount"; public const string ACCOUNT_ADDED = "accountAdded"; public const string SWITCHED_ACCOUNT = "switchedAccount"; + public const string ACCOUNT_SWITCH_COMPLETED = "accountSwitchCompleted"; } } diff --git a/src/iOS.Core/Utilities/iOSCoreHelpers.cs b/src/iOS.Core/Utilities/iOSCoreHelpers.cs index 685edc213..3d7b556ef 100644 --- a/src/iOS.Core/Utilities/iOSCoreHelpers.cs +++ b/src/iOS.Core/Utilities/iOSCoreHelpers.cs @@ -222,7 +222,8 @@ namespace Bit.iOS.Core.Utilities ServiceContainer.Resolve("stateService"), ServiceContainer.Resolve("platformUtilsService"), ServiceContainer.Resolve("authService"), - ServiceContainer.Resolve("logger")); + ServiceContainer.Resolve("logger"), + ServiceContainer.Resolve("messagingService")); ServiceContainer.Register("accountsManager", accountsManager); if (postBootstrapFunc != null)