1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-01 16:12:49 -05:00

premium checks on 2fa providers

This commit is contained in:
Kyle Spearrin
2017-07-06 16:56:12 -04:00
parent 99c1d68f5a
commit 295d6510a9
7 changed files with 79 additions and 5 deletions

View File

@ -90,7 +90,7 @@ namespace Bit.Core.Models.Table
return false;
}
return providers[provider].Enabled;
return providers[provider].Enabled && (Premium || !TwoFactorProvider.RequiresPremium(provider));
}
public bool TwoFactorIsEnabled()
@ -101,7 +101,7 @@ namespace Bit.Core.Models.Table
return false;
}
return providers.Any(p => p.Value?.Enabled ?? false);
return providers.Any(p => (p.Value?.Enabled ?? false) && (Premium || !TwoFactorProvider.RequiresPremium(p.Key)));
}
public TwoFactorProvider GetTwoFactorProvider(TwoFactorProviderType provider)

View File

@ -1,4 +1,5 @@
using Newtonsoft.Json;
using Bit.Core.Enums;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using U2F.Core.Utils;
@ -38,5 +39,18 @@ namespace Bit.Core.Models
public uint Counter { get; set; }
public bool Compromised { get; set; }
}
public static bool RequiresPremium(TwoFactorProviderType type)
{
switch(type)
{
case TwoFactorProviderType.Duo:
case TwoFactorProviderType.YubiKey:
case TwoFactorProviderType.U2f:
return true;
default:
return false;
}
}
}
}