From e9afc75f0a6d28d6ad57140c8207310c17406469 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Bispo?= Date: Tue, 8 Aug 2023 20:15:35 +0100 Subject: [PATCH] [PM-3333] Check for purged admin auth requests (#2671) * [PM-3333] Check for purged admin auth requests Co-authored-by: Federico Maccaroni --------- Co-authored-by: Federico Maccaroni --- src/App/Pages/Accounts/LoginSsoPageViewModel.cs | 1 + src/Core/Services/AuthService.cs | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/App/Pages/Accounts/LoginSsoPageViewModel.cs b/src/App/Pages/Accounts/LoginSsoPageViewModel.cs index ad474820c..748ad2372 100644 --- a/src/App/Pages/Accounts/LoginSsoPageViewModel.cs +++ b/src/App/Pages/Accounts/LoginSsoPageViewModel.cs @@ -246,6 +246,7 @@ namespace Bit.App.Pages } else { + await _stateService.SetPendingAdminAuthRequestAsync(null); StartDeviceApprovalOptionsAction?.Invoke(); } } diff --git a/src/Core/Services/AuthService.cs b/src/Core/Services/AuthService.cs index 5e1248702..7b7e8ab57 100644 --- a/src/Core/Services/AuthService.cs +++ b/src/Core/Services/AuthService.cs @@ -610,8 +610,16 @@ namespace Bit.Core.Services } public async Task GetPasswordlessLoginRequestByIdAsync(string id) { - var response = await _apiService.GetAuthRequestAsync(id); - return await PopulateFingerprintPhraseAsync(response, await _stateService.GetEmailAsync()); + try + { + var response = await _apiService.GetAuthRequestAsync(id); + return await PopulateFingerprintPhraseAsync(response, await _stateService.GetEmailAsync()); + } + catch (ApiException ex) when (ex.Error?.StatusCode == System.Net.HttpStatusCode.NotFound) + { + // Thrown when request expires and purge job erases it from the db + return null; + } } ///