diff --git a/src/App/Pages/Vault/AddEditPage.xaml.cs b/src/App/Pages/Vault/AddEditPage.xaml.cs index 666c60c35..8b0fba354 100644 --- a/src/App/Pages/Vault/AddEditPage.xaml.cs +++ b/src/App/Pages/Vault/AddEditPage.xaml.cs @@ -54,7 +54,14 @@ namespace Bit.App.Pages protected override async void OnAppearing() { base.OnAppearing(); - await LoadOnAppearedAsync(_scrollView, true, () => _vm.LoadAsync(_appOptions)); + await LoadOnAppearedAsync(_scrollView, true, async () => + { + var success = await _vm.LoadAsync(); + if(!success) + { + await Navigation.PopModalAsync(); + } + }); if(_vm.EditMode && Device.RuntimePlatform == Device.Android) { if(_vm.Cipher.OrganizationId == null) diff --git a/src/App/Pages/Vault/AddEditPageViewModel.cs b/src/App/Pages/Vault/AddEditPageViewModel.cs index cf1488dc2..921c93c4d 100644 --- a/src/App/Pages/Vault/AddEditPageViewModel.cs +++ b/src/App/Pages/Vault/AddEditPageViewModel.cs @@ -267,7 +267,7 @@ namespace Bit.App.Pages PageTitle = EditMode ? AppResources.EditItem : AppResources.AddItem; } - public async Task LoadAsync(AppOptions appOptions = null) + public async Task LoadAsync(AppOptions appOptions = null) { var myEmail = await _userService.GetEmailAsync(); OwnershipOptions.Add(new KeyValuePair(myEmail, null)); @@ -296,6 +296,10 @@ namespace Bit.App.Pages if(EditMode) { var cipher = await _cipherService.GetAsync(CipherId); + if(cipher == null) + { + return false; + } Cipher = await cipher.DecryptAsync(); } else @@ -358,6 +362,7 @@ namespace Bit.App.Pages Fields.ResetWithRange(Cipher.Fields?.Select(f => new AddEditPageFieldViewModel(f))); } } + return true; } public async Task SubmitAsync() diff --git a/src/App/Pages/Vault/ViewPage.xaml.cs b/src/App/Pages/Vault/ViewPage.xaml.cs index f64d8f86f..3eecc53d4 100644 --- a/src/App/Pages/Vault/ViewPage.xaml.cs +++ b/src/App/Pages/Vault/ViewPage.xaml.cs @@ -49,7 +49,14 @@ namespace Bit.App.Pages } } }); - await LoadOnAppearedAsync(_scrollView, true, () => _vm.LoadAsync(), _mainContent); + await LoadOnAppearedAsync(_scrollView, true, async () => + { + var success = await _vm.LoadAsync(); + if(!success) + { + await Navigation.PopModalAsync(); + } + }, _mainContent); if(Device.RuntimePlatform == Device.Android) { if(_vm.Cipher.OrganizationId == null) diff --git a/src/App/Pages/Vault/ViewPageViewModel.cs b/src/App/Pages/Vault/ViewPageViewModel.cs index 8baa0e2f3..903450c63 100644 --- a/src/App/Pages/Vault/ViewPageViewModel.cs +++ b/src/App/Pages/Vault/ViewPageViewModel.cs @@ -206,10 +206,14 @@ namespace Bit.App.Pages } } - public async Task LoadAsync() + public async Task LoadAsync() { CleanUp(); var cipher = await _cipherService.GetAsync(CipherId); + if(cipher == null) + { + return false; + } Cipher = await cipher.DecryptAsync(); CanAccessPremium = await _userService.CanAccessPremiumAsync(); Fields = Cipher.Fields?.Select(f => new ViewPageFieldViewModel(f)).ToList(); @@ -231,6 +235,7 @@ namespace Bit.App.Pages return true; }); } + return true; } public void CleanUp()