2025-07-08 10:25:41 -04:00
|
|
|
|
// FIXME: Update this file to be null safe and then delete the line below
|
|
|
|
|
|
#nullable disable
|
|
|
|
|
|
|
|
|
|
|
|
using Bit.Core.Auth.Enums;
|
2023-04-14 13:25:56 -04:00
|
|
|
|
using Bit.Core.Entities;
|
2021-12-14 15:05:07 +00:00
|
|
|
|
using Bit.Core.Models.Api;
|
2017-06-19 22:08:10 -04:00
|
|
|
|
|
2023-04-14 13:25:56 -04:00
|
|
|
|
namespace Bit.Api.Auth.Models.Response.TwoFactor;
|
2022-08-29 16:06:55 -04:00
|
|
|
|
|
2017-06-19 22:08:10 -04:00
|
|
|
|
public class TwoFactorEmailResponseModel : ResponseModel
|
|
|
|
|
|
{
|
|
|
|
|
|
public TwoFactorEmailResponseModel(User user)
|
|
|
|
|
|
: base("twoFactorEmail")
|
|
|
|
|
|
{
|
|
|
|
|
|
if (user == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new ArgumentNullException(nameof(user));
|
|
|
|
|
|
}
|
2022-08-29 14:53:16 -04:00
|
|
|
|
|
2017-06-19 22:08:10 -04:00
|
|
|
|
var provider = user.GetTwoFactorProvider(TwoFactorProviderType.Email);
|
2025-06-02 18:18:28 +02:00
|
|
|
|
if (provider?.MetaData?.TryGetValue("Email", out var email) ?? false)
|
2017-06-19 22:08:10 -04:00
|
|
|
|
{
|
2025-06-02 18:18:28 +02:00
|
|
|
|
Email = (string)email;
|
2017-06-19 22:08:10 -04:00
|
|
|
|
Enabled = provider.Enabled;
|
|
|
|
|
|
}
|
2022-08-29 16:06:55 -04:00
|
|
|
|
else
|
|
|
|
|
|
{
|
2017-06-19 22:08:10 -04:00
|
|
|
|
Enabled = false;
|
2022-08-29 16:06:55 -04:00
|
|
|
|
}
|
2022-08-29 15:53:48 -04:00
|
|
|
|
}
|
2022-08-29 16:06:55 -04:00
|
|
|
|
|
2017-06-19 22:08:10 -04:00
|
|
|
|
public bool Enabled { get; set; }
|
|
|
|
|
|
public string Email { get; set; }
|
|
|
|
|
|
}
|