1
0
mirror of https://github.com/bitwarden/server.git synced 2025-06-30 15:42:48 -05:00

move some 2fa logic functions to userService

This commit is contained in:
Kyle Spearrin
2018-12-19 10:47:53 -05:00
parent b7362ae741
commit ac7c7b5077
15 changed files with 64 additions and 61 deletions

View File

@ -92,48 +92,6 @@ namespace Bit.Core.Models.Table
_twoFactorProviders = providers;
}
public async Task<bool> TwoFactorProviderIsEnabledAsync(TwoFactorProviderType provider,
IUserService userService)
{
var providers = GetTwoFactorProviders();
if(providers == null || !providers.ContainsKey(provider) || !providers[provider].Enabled)
{
return false;
}
if(!TwoFactorProvider.RequiresPremium(provider))
{
return true;
}
return await userService.CanAccessPremium(this);
}
public async Task<bool> TwoFactorIsEnabledAsync(IUserService userService)
{
var providers = GetTwoFactorProviders();
if(providers == null)
{
return false;
}
foreach(var p in providers)
{
if(p.Value?.Enabled ?? false)
{
if(!TwoFactorProvider.RequiresPremium(p.Key))
{
return true;
}
if(await userService.CanAccessPremium(this))
{
return true;
}
}
}
return false;
}
public TwoFactorProvider GetTwoFactorProvider(TwoFactorProviderType provider)
{
var providers = GetTwoFactorProviders();