mirror of
https://github.com/bitwarden/server.git
synced 2025-06-13 14:30:50 -05:00

* Avoid multiple lookups in dictionaries * Consistency in fallback to empty CollectionIds * Readability at the cost of lines changed * Readability * Changes after running dotnet format
32 lines
787 B
C#
32 lines
787 B
C#
using Bit.Core.Auth.Enums;
|
|
using Bit.Core.Entities;
|
|
using Bit.Core.Models.Api;
|
|
|
|
namespace Bit.Api.Auth.Models.Response.TwoFactor;
|
|
|
|
public class TwoFactorEmailResponseModel : ResponseModel
|
|
{
|
|
public TwoFactorEmailResponseModel(User user)
|
|
: base("twoFactorEmail")
|
|
{
|
|
if (user == null)
|
|
{
|
|
throw new ArgumentNullException(nameof(user));
|
|
}
|
|
|
|
var provider = user.GetTwoFactorProvider(TwoFactorProviderType.Email);
|
|
if (provider?.MetaData?.TryGetValue("Email", out var email) ?? false)
|
|
{
|
|
Email = (string)email;
|
|
Enabled = provider.Enabled;
|
|
}
|
|
else
|
|
{
|
|
Enabled = false;
|
|
}
|
|
}
|
|
|
|
public bool Enabled { get; set; }
|
|
public string Email { get; set; }
|
|
}
|