1
0
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:
Kyle Spearrin
2017-06-20 10:08:59 -04:00
parent 475160cfe1
commit 612697e815
8 changed files with 79 additions and 159 deletions

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);