diff --git a/src/Core/Services/StateService.cs b/src/Core/Services/StateService.cs index 5988919299f..5e04b6e3cf6 100644 --- a/src/Core/Services/StateService.cs +++ b/src/Core/Services/StateService.cs @@ -526,8 +526,7 @@ public async Task SetLastActiveTimeAsync(long? value, string userId = null) { var reconciledOptions = ReconcileOptions(new StorageOptions { UserId = userId }, await GetDefaultStorageOptionsAsync()); - return await GetValueAsync(Constants.VaultTimeoutKey(reconciledOptions.UserId), reconciledOptions) ?? - Constants.VaultTimeoutDefault; + return await GetValueAsync(Constants.VaultTimeoutKey(reconciledOptions.UserId), reconciledOptions); } public async Task SetVaultTimeoutAsync(int? value, string userId = null) @@ -542,7 +541,7 @@ public async Task SetVaultTimeoutAsync(int? value, string userId = null) var reconciledOptions = ReconcileOptions(new StorageOptions { UserId = userId }, await GetDefaultStorageOptionsAsync()); return await GetValueAsync(Constants.VaultTimeoutActionKey(reconciledOptions.UserId), - reconciledOptions) ?? VaultTimeoutAction.Lock; + reconciledOptions); } public async Task SetVaultTimeoutActionAsync(VaultTimeoutAction? value, string userId = null) @@ -1444,6 +1443,14 @@ private async Task ScaffoldNewAccountAsync(Account account) } _state.Accounts[account.Profile.UserId] = account; } + + // Check if account has logged in before by checking a guaranteed non-null pref + if (await GetVaultTimeoutActionAsync(account.Profile.UserId) == null) + { + // Account has never logged in, set defaults + await SetVaultTimeoutAsync(Constants.VaultTimeoutDefault, account.Profile.UserId); + await SetVaultTimeoutActionAsync(VaultTimeoutAction.Lock, account.Profile.UserId); + } } private StorageOptions ReconcileOptions(StorageOptions requestedOptions, StorageOptions defaultOptions)