diff --git a/src/App/Pages/Settings/SettingsPage/SettingsPageViewModel.cs b/src/App/Pages/Settings/SettingsPage/SettingsPageViewModel.cs index 5a2f1c827..8a42efa82 100644 --- a/src/App/Pages/Settings/SettingsPage/SettingsPageViewModel.cs +++ b/src/App/Pages/Settings/SettingsPage/SettingsPageViewModel.cs @@ -131,13 +131,13 @@ namespace Bit.App.Pages _vaultTimeoutDisplayValue ??= _vaultTimeoutOptions.Where(o => o.Value == CustomVaultTimeoutValue).First().Key; var savedVaultTimeoutAction = await _vaultTimeoutService.GetVaultTimeoutAction(); - var action = savedVaultTimeoutAction ?? VaultTimeoutAction.Lock; - if (!_hasMasterPassword && savedVaultTimeoutAction == null) + var timeoutAction = savedVaultTimeoutAction ?? VaultTimeoutAction.Lock; + if (!_hasMasterPassword && timeoutAction == VaultTimeoutAction.Lock) { - action = VaultTimeoutAction.Logout; + timeoutAction = VaultTimeoutAction.Logout; await _vaultTimeoutService.SetVaultTimeoutOptionsAsync(_vaultTimeout, VaultTimeoutAction.Logout); } - _vaultTimeoutActionDisplayValue = _vaultTimeoutActionOptions.FirstOrDefault(o => o.Value == action).Key; + _vaultTimeoutActionDisplayValue = _vaultTimeoutActionOptions.FirstOrDefault(o => o.Value == timeoutAction).Key; if (await _policyService.PolicyAppliesToUser(PolicyType.MaximumVaultTimeout)) { diff --git a/src/Core/Services/StateService.cs b/src/Core/Services/StateService.cs index b57fa783e..ea032ea5d 100644 --- a/src/Core/Services/StateService.cs +++ b/src/Core/Services/StateService.cs @@ -1334,16 +1334,21 @@ namespace Bit.Core.Services public async Task GetPendingAdminAuthRequestAsync(string userId = null) { - var reconciledOptions = ReconcileOptions(new StorageOptions { UserId = userId }, - await GetDefaultStorageOptionsAsync()); - return await _storageMediatorService.GetAsync(Constants.PendingAdminAuthRequest(reconciledOptions.UserId), true); + try + { + // GetAsync will throw an ArgumentException exception if there isn't a value to deserialize + return await _storageMediatorService.GetAsync(await ComposeKeyAsync(Constants.PendingAdminAuthRequest, userId), true); + } + catch (ArgumentException) + { + return null; + } + } public async Task SetPendingAdminAuthRequestAsync(PendingAdminAuthRequest value, string userId = null) { - var reconciledOptions = ReconcileOptions(new StorageOptions { UserId = userId }, - await GetDefaultStorageOptionsAsync()); - await _storageMediatorService.SaveAsync(Constants.PendingAdminAuthRequest(reconciledOptions.UserId), value, true); + await _storageMediatorService.SaveAsync(await ComposeKeyAsync(Constants.PendingAdminAuthRequest, userId), value, true); } public ConfigResponse GetConfigs()