1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-07 10:55:43 -05:00

refactor code to with user TwoFactorProviders

This commit is contained in:
Kyle Spearrin
2017-06-07 14:14:34 -04:00
parent d8c0994ed3
commit ecc2468409
10 changed files with 166 additions and 53 deletions

View File

@ -22,7 +22,7 @@ namespace Bit.Core.Models.Api
Email = user.Email;
MasterPasswordHint = string.IsNullOrWhiteSpace(user.MasterPasswordHint) ? null : user.MasterPasswordHint;
Culture = user.Culture;
TwoFactorEnabled = user.TwoFactorEnabled;
TwoFactorEnabled = user.TwoFactorIsEnabled();
Key = user.Key;
PrivateKey = user.PrivateKey;
SecurityStamp = user.SecurityStamp;

View File

@ -14,8 +14,25 @@ namespace Bit.Core.Models.Api
throw new ArgumentNullException(nameof(user));
}
TwoFactorEnabled = user.TwoFactorEnabled;
AuthenticatorKey = user.AuthenticatorKey;
var providers = user.GetTwoFactorProviders();
if(user.TwoFactorProvider.HasValue && providers.ContainsKey(user.TwoFactorProvider.Value))
{
var provider = providers[user.TwoFactorProvider.Value];
switch(user.TwoFactorProvider.Value)
{
case TwoFactorProviderType.Authenticator:
AuthenticatorKey = provider.MetaData["Key"];
break;
default:
break;
}
}
else
{
TwoFactorEnabled = false;
}
TwoFactorEnabled = user.TwoFactorIsEnabled();
TwoFactorProvider = user.TwoFactorProvider;
TwoFactorRecoveryCode = user.TwoFactorRecoveryCode;
}