mirror of
https://github.com/bitwarden/server.git
synced 2025-07-04 09:32:48 -05:00
[PM-14476] Avoid multiple lookups in dictionaries (#4973)
* Avoid multiple lookups in dictionaries * Consistency in fallback to empty CollectionIds * Readability at the cost of lines changed * Readability * Changes after running dotnet format
This commit is contained in:
@ -257,12 +257,12 @@ public class Organization : ITableObject<Guid>, IStorableSubscriber, IRevisable
|
||||
public bool TwoFactorProviderIsEnabled(TwoFactorProviderType provider)
|
||||
{
|
||||
var providers = GetTwoFactorProviders();
|
||||
if (providers == null || !providers.ContainsKey(provider))
|
||||
if (providers == null || !providers.TryGetValue(provider, out var twoFactorProvider))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return providers[provider].Enabled && Use2fa;
|
||||
return twoFactorProvider.Enabled && Use2fa;
|
||||
}
|
||||
|
||||
public bool TwoFactorIsEnabled()
|
||||
@ -279,12 +279,7 @@ public class Organization : ITableObject<Guid>, IStorableSubscriber, IRevisable
|
||||
public TwoFactorProvider? GetTwoFactorProvider(TwoFactorProviderType provider)
|
||||
{
|
||||
var providers = GetTwoFactorProviders();
|
||||
if (providers == null || !providers.ContainsKey(provider))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return providers[provider];
|
||||
return providers?.GetValueOrDefault(provider);
|
||||
}
|
||||
|
||||
public void UpdateFromLicense(OrganizationLicense license, IFeatureService featureService)
|
||||
|
Reference in New Issue
Block a user