1
0
mirror of https://github.com/bitwarden/server synced 2026-01-08 03:23:20 +00:00

Parse enum as to accept 0 values or full string values

This commit is contained in:
Kyle Spearrin
2017-01-28 17:28:28 -05:00
parent 4354006a27
commit 8514d1f16d
4 changed files with 15 additions and 7 deletions

View File

@@ -76,14 +76,21 @@ namespace Bit.Api.IdentityServer
{
if(await _userManager.CheckPasswordAsync(user, context.Password))
{
TwoFactorProviderType twoFactorProviderType = TwoFactorProviderType.Authenticator; // Just defaulting it
if(!twoFactorRequest && await TwoFactorRequiredAsync(user))
{
BuildTwoFactorResult(user, context);
return;
}
if(twoFactorRequest && !Enum.TryParse(twoFactorProvider, out twoFactorProviderType))
{
BuildTwoFactorResult(user, context);
return;
}
if(!twoFactorRequest ||
await _userManager.VerifyTwoFactorTokenAsync(user, twoFactorProvider, twoFactorToken))
await _userManager.VerifyTwoFactorTokenAsync(user, twoFactorProviderType.ToString(), twoFactorToken))
{
var device = await SaveDeviceAsync(user, context);
BuildSuccessResult(user, context, device);