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:
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user