MaximumVaultTimeout policy fixes (#1573)

This commit is contained in:
Oscar Hinton 2021-10-12 15:35:01 +02:00 committed by GitHub
parent 34aba0e168
commit c9ce7256e5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 20 deletions

View file

@ -418,25 +418,6 @@ namespace Bit.App.Pages
new SettingsPageListItem { Name = AppResources.LockNow }, new SettingsPageListItem { Name = AppResources.LockNow },
new SettingsPageListItem { Name = AppResources.TwoStepLogin } new SettingsPageListItem { Name = AppResources.TwoStepLogin }
}; };
if (_vaultTimeoutDisplayValue == AppResources.Custom)
{
securityItems.Insert(1, new SettingsPageListItem
{
Name = AppResources.Custom,
Time = TimeSpan.FromMinutes(Math.Abs((double) _vaultTimeout)),
});
}
if (_vaultTimeoutPolicy != null)
{
var maximumTimeout = _policyService.GetPolicyInt(_vaultTimeoutPolicy, "minutes").GetValueOrDefault();
securityItems.Insert(0, new SettingsPageListItem
{
Name = string.Format(AppResources.VaultTimeoutPolicyInEffect,
Math.Floor((float) maximumTimeout / 60),
maximumTimeout % 60),
UseFrame = true,
});
}
if (_supportsBiometric || _biometric) if (_supportsBiometric || _biometric)
{ {
var biometricName = AppResources.Biometrics; var biometricName = AppResources.Biometrics;
@ -452,6 +433,25 @@ namespace Bit.App.Pages
}; };
securityItems.Insert(2, item); securityItems.Insert(2, item);
} }
if (_vaultTimeoutDisplayValue == AppResources.Custom)
{
securityItems.Insert(1, new SettingsPageListItem
{
Name = AppResources.Custom,
Time = TimeSpan.FromMinutes(Math.Abs((double)_vaultTimeout)),
});
}
if (_vaultTimeoutPolicy != null)
{
var maximumTimeout = _policyService.GetPolicyInt(_vaultTimeoutPolicy, "minutes").GetValueOrDefault();
securityItems.Insert(0, new SettingsPageListItem
{
Name = string.Format(AppResources.VaultTimeoutPolicyInEffect,
Math.Floor((float)maximumTimeout / 60),
maximumTimeout % 60),
UseFrame = true,
});
}
var accountItems = new List<SettingsPageListItem> var accountItems = new List<SettingsPageListItem>
{ {
new SettingsPageListItem { Name = AppResources.FingerprintPhrase }, new SettingsPageListItem { Name = AppResources.FingerprintPhrase },

View file

@ -220,10 +220,20 @@ namespace Bit.Core.Services
o.Enabled && o.Enabled &&
o.Status >= OrganizationUserStatusType.Accepted && o.Status >= OrganizationUserStatusType.Accepted &&
o.UsePolicies && o.UsePolicies &&
!o.isExemptFromPolicies && !isExcemptFromPolicies(o, policyType) &&
policySet.Contains(o.Id)); policySet.Contains(o.Id));
} }
private bool isExcemptFromPolicies(Organization organization, PolicyType policyType)
{
if (policyType == PolicyType.MaximumVaultTimeout)
{
return organization.Type == OrganizationUserType.Owner;
}
return organization.isExemptFromPolicies;
}
public int? GetPolicyInt(Policy policy, string key) public int? GetPolicyInt(Policy policy, string key)
{ {
if (policy.Data.ContainsKey(key)) if (policy.Data.ContainsKey(key))