MireaBackend/Endpoint/Common/MapperDto/TwoFactorAuthenticationConverter.cs

23 lines
1.1 KiB
C#
Raw Normal View History

2024-11-02 01:05:24 +03:00
using Mirea.Api.Dto.Common;
using System;
namespace Mirea.Api.Endpoint.Common.MapperDto;
public static class TwoFactorAuthenticationConverter
{
2024-12-26 13:38:43 +03:00
public static TwoFactorAuthentication ConvertToDto(this Security.Common.Model.TwoFactorAuthenticator authenticator) =>
2024-11-02 01:05:24 +03:00
authenticator switch
{
2024-12-26 13:38:43 +03:00
Security.Common.Model.TwoFactorAuthenticator.None => TwoFactorAuthentication.None,
Security.Common.Model.TwoFactorAuthenticator.Totp => TwoFactorAuthentication.TotpRequired,
2024-11-02 01:05:24 +03:00
_ => throw new ArgumentOutOfRangeException(nameof(authenticator), authenticator, null)
};
2024-12-26 13:38:43 +03:00
public static Security.Common.Model.TwoFactorAuthenticator ConvertFromDto(this TwoFactorAuthentication authentication) =>
2024-11-02 01:05:24 +03:00
authentication switch
{
2024-12-26 13:38:43 +03:00
TwoFactorAuthentication.None => Security.Common.Model.TwoFactorAuthenticator.None,
TwoFactorAuthentication.TotpRequired => Security.Common.Model.TwoFactorAuthenticator.Totp,
2024-11-02 01:05:24 +03:00
_ => throw new ArgumentOutOfRangeException(nameof(authentication), authentication, null)
};
}