Skip to content

Commit

Permalink
[PM-1567] Fix for vault timeout 'never' not persisting (#2440)
Browse files Browse the repository at this point in the history
  • Loading branch information
mpbw2 committed Mar 27, 2023
1 parent 9a027ea commit 8e3521f
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/Core/Services/StateService.cs
Expand Up @@ -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<int?>(Constants.VaultTimeoutKey(reconciledOptions.UserId), reconciledOptions) ??
Constants.VaultTimeoutDefault;
return await GetValueAsync<int?>(Constants.VaultTimeoutKey(reconciledOptions.UserId), reconciledOptions);
}

public async Task SetVaultTimeoutAsync(int? value, string userId = null)
Expand All @@ -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<VaultTimeoutAction?>(Constants.VaultTimeoutActionKey(reconciledOptions.UserId),
reconciledOptions) ?? VaultTimeoutAction.Lock;
reconciledOptions);
}

public async Task SetVaultTimeoutActionAsync(VaultTimeoutAction? value, string userId = null)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 8e3521f

Please sign in to comment.