Files
server/src/Api/Models/Response/TwoFactor/TwoFactorYubiKeyResponseModel.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

61 lines
1.7 KiB
C#
Raw Normal View History

using Bit.Core.Entities;
using Bit.Core.Enums;
2021-12-14 15:05:07 +00:00
using Bit.Core.Models.Api;
2021-12-14 15:05:07 +00:00
namespace Bit.Api.Models.Response.TwoFactor;
2022-08-29 14:53:16 -04:00
public class TwoFactorYubiKeyResponseModel : ResponseModel
{
public TwoFactorYubiKeyResponseModel(User user)
: base("twoFactorYubiKey")
{
if (user == null)
{
throw new ArgumentNullException(nameof(user));
2022-08-29 14:53:16 -04:00
}
var provider = user.GetTwoFactorProvider(TwoFactorProviderType.YubiKey);
if (provider?.MetaData != null && provider.MetaData.Count > 0)
2022-08-29 14:53:16 -04:00
{
Enabled = provider.Enabled;
2022-08-29 14:53:16 -04:00
if (provider.MetaData.ContainsKey("Key1"))
{
Key1 = (string)provider.MetaData["Key1"];
}
if (provider.MetaData.ContainsKey("Key2"))
{
2017-06-21 21:46:52 -04:00
Key2 = (string)provider.MetaData["Key2"];
}
if (provider.MetaData.ContainsKey("Key3"))
{
2017-06-21 21:46:52 -04:00
Key3 = (string)provider.MetaData["Key3"];
}
if (provider.MetaData.ContainsKey("Key4"))
{
Key4 = (string)provider.MetaData["Key4"];
2022-08-29 14:53:16 -04:00
}
if (provider.MetaData.ContainsKey("Key5"))
2022-08-29 14:53:16 -04:00
{
2017-06-21 21:46:52 -04:00
Key5 = (string)provider.MetaData["Key5"];
2022-08-29 14:53:16 -04:00
}
if (provider.MetaData.ContainsKey("Nfc"))
2022-08-29 14:53:16 -04:00
{
2017-06-29 12:34:10 -04:00
Nfc = (bool)provider.MetaData["Nfc"];
}
}
2022-08-29 14:53:16 -04:00
else
{
Enabled = false;
2017-06-29 12:34:10 -04:00
}
}
2022-08-29 14:53:16 -04:00
2017-06-29 12:34:10 -04:00
public bool Enabled { get; set; }
public string Key1 { get; set; }
public string Key2 { get; set; }
public string Key3 { get; set; }
public string Key4 { get; set; }
public string Key5 { get; set; }
2017-06-29 12:34:10 -04:00
public bool Nfc { get; set; }
}