From 34fd30e157aa3ee7370fbadc28776ce37631e095 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Bispo?= Date: Thu, 17 Nov 2022 16:02:34 +0000 Subject: [PATCH] [SG-831] Pull Down Sync does not retrieve pending AuthRequests (#2196) * [SG-831] Pull to refresh forces refresh. * [SG-831] Expose sync login request method to be used independently * [SG-831] Change sync order --- src/App/Pages/Settings/SyncPageViewModel.cs | 1 + src/App/Pages/Vault/GroupingsPage/GroupingsPageViewModel.cs | 1 + src/Core/Abstractions/ISyncService.cs | 2 ++ src/Core/Services/SyncService.cs | 4 ++-- 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/App/Pages/Settings/SyncPageViewModel.cs b/src/App/Pages/Settings/SyncPageViewModel.cs index 7aade221b..a98e12617 100644 --- a/src/App/Pages/Settings/SyncPageViewModel.cs +++ b/src/App/Pages/Settings/SyncPageViewModel.cs @@ -90,6 +90,7 @@ namespace Bit.App.Pages try { await _deviceActionService.ShowLoadingAsync(AppResources.Syncing); + await _syncService.SyncPasswordlessLoginRequestsAsync(); var success = await _syncService.FullSyncAsync(true); await _deviceActionService.HideLoadingAsync(); if (success) diff --git a/src/App/Pages/Vault/GroupingsPage/GroupingsPageViewModel.cs b/src/App/Pages/Vault/GroupingsPage/GroupingsPageViewModel.cs index 45014b262..36b7d71da 100644 --- a/src/App/Pages/Vault/GroupingsPage/GroupingsPageViewModel.cs +++ b/src/App/Pages/Vault/GroupingsPage/GroupingsPageViewModel.cs @@ -189,6 +189,7 @@ namespace Bit.App.Pages if (await _stateService.GetSyncOnRefreshAsync() && Refreshing && !SyncRefreshing) { SyncRefreshing = true; + await _syncService.SyncPasswordlessLoginRequestsAsync(); await _syncService.FullSyncAsync(false); return; } diff --git a/src/Core/Abstractions/ISyncService.cs b/src/Core/Abstractions/ISyncService.cs index 7cfe707e6..aeb0205b1 100644 --- a/src/Core/Abstractions/ISyncService.cs +++ b/src/Core/Abstractions/ISyncService.cs @@ -14,5 +14,7 @@ namespace Bit.Core.Abstractions Task SyncDeleteFolderAsync(SyncFolderNotification notification); Task SyncUpsertCipherAsync(SyncCipherNotification notification, bool isEdit); Task SyncUpsertFolderAsync(SyncFolderNotification notification, bool isEdit); + // Passwordless code will be moved to an independent service in future techdept + Task SyncPasswordlessLoginRequestsAsync(); } } diff --git a/src/Core/Services/SyncService.cs b/src/Core/Services/SyncService.cs index 97f9392c1..cf3db3a7e 100644 --- a/src/Core/Services/SyncService.cs +++ b/src/Core/Services/SyncService.cs @@ -111,7 +111,6 @@ namespace Bit.Core.Services await SyncSettingsAsync(userId, response.Domains); await SyncPoliciesAsync(response.Policies); await SyncSendsAsync(userId, response.Sends); - await SyncPasswordlessLoginRequestsAsync(userId); await SetLastSyncAsync(now); return SyncCompleted(true); } @@ -387,10 +386,11 @@ namespace Bit.Core.Services await _sendService.ReplaceAsync(sends); } - private async Task SyncPasswordlessLoginRequestsAsync(string userId) + public async Task SyncPasswordlessLoginRequestsAsync() { try { + var userId = await _stateService.GetActiveUserIdAsync(); // if the user has not enabled passwordless logins ignore requests if (!await _stateService.GetApprovePasswordlessLoginsAsync(userId)) {