mirror of
https://github.com/bitwarden/server
synced 2026-01-03 17:14:00 +00:00
refactorings around two-factor controller
This commit is contained in:
@@ -14,8 +14,6 @@ namespace Bit.Core.Identity
|
||||
var provider = user.GetTwoFactorProvider(TwoFactorProviderType.Authenticator);
|
||||
|
||||
var canGenerate = user.TwoFactorProviderIsEnabled(TwoFactorProviderType.Authenticator)
|
||||
&& user.TwoFactorProvider.HasValue
|
||||
&& user.TwoFactorProvider.Value == TwoFactorProviderType.Authenticator
|
||||
&& !string.IsNullOrWhiteSpace(provider.MetaData["Key"]);
|
||||
|
||||
return Task.FromResult(canGenerate);
|
||||
|
||||
@@ -13,10 +13,7 @@ namespace Bit.Core.Identity
|
||||
public Task<bool> CanGenerateTwoFactorTokenAsync(UserManager<User> manager, User user)
|
||||
{
|
||||
var provider = user.GetTwoFactorProvider(TwoFactorProviderType.Duo);
|
||||
|
||||
var canGenerate = user.TwoFactorProviderIsEnabled(TwoFactorProviderType.Duo)
|
||||
&& user.TwoFactorProvider.HasValue
|
||||
&& user.TwoFactorProvider.Value == TwoFactorProviderType.Duo
|
||||
&& !string.IsNullOrWhiteSpace(provider?.MetaData["UserId"]);
|
||||
|
||||
return Task.FromResult(canGenerate);
|
||||
|
||||
@@ -19,10 +19,7 @@ namespace Bit.Core.Identity
|
||||
public Task<bool> CanGenerateTwoFactorTokenAsync(UserManager<User> manager, User user)
|
||||
{
|
||||
var provider = user.GetTwoFactorProvider(TwoFactorProviderType.YubiKey);
|
||||
|
||||
var canGenerate = user.TwoFactorProviderIsEnabled(TwoFactorProviderType.YubiKey)
|
||||
&& user.TwoFactorProvider.HasValue
|
||||
&& user.TwoFactorProvider.Value == TwoFactorProviderType.YubiKey
|
||||
&& (provider?.MetaData.Values.Any(v => !string.IsNullOrWhiteSpace(v)) ?? false);
|
||||
|
||||
return Task.FromResult(canGenerate);
|
||||
|
||||
Reference in New Issue
Block a user