From 2841a0e28d505b142fb447a98a883317698e621f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Bispo?= Date: Fri, 18 Aug 2023 23:05:52 +0100 Subject: [PATCH] [PM-3513] Show error SSO policy (#2707) * [PM-3513] Show API error when SSO policy is enforced. (cherry picked from commit e274c0410749a8c87ec35abce47b9e58bf3ce43c) --- .../Accounts/LoginPasswordlessRequestViewModel.cs | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/App/Pages/Accounts/LoginPasswordlessRequestViewModel.cs b/src/App/Pages/Accounts/LoginPasswordlessRequestViewModel.cs index 313ae21fc..410832e77 100644 --- a/src/App/Pages/Accounts/LoginPasswordlessRequestViewModel.cs +++ b/src/App/Pages/Accounts/LoginPasswordlessRequestViewModel.cs @@ -12,6 +12,7 @@ using Bit.App.Utilities; using Bit.Core; using Bit.Core.Abstractions; using Bit.Core.Enums; +using Bit.Core.Exceptions; using Bit.Core.Models.Domain; using Bit.Core.Models.Response; using Bit.Core.Services; @@ -277,6 +278,10 @@ namespace Bit.App.Pages await HandleLoginCompleteAsync(); } } + catch (ApiException ex) when (ex.Error?.StatusCode == System.Net.HttpStatusCode.BadRequest) + { + HandleException(ex); + } catch (Exception ex) { StartCheckLoginRequestStatus(); @@ -344,16 +349,6 @@ namespace Bit.App.Pages _requestAccessCode = response.RequestAccessCode; _requestKeyPair = response.RequestKeyPair; } - - private void HandleException(Exception ex) - { - Xamarin.Essentials.MainThread.InvokeOnMainThreadAsync(async () => - { - await _deviceActionService.HideLoadingAsync(); - await _platformUtilsService.ShowDialogAsync(AppResources.GenericErrorMessage); - }).FireAndForget(); - _logger.Exception(ex); - } } }