refactor: add user converter
This commit is contained in:
parent
c75ac60b0b
commit
9d5007ef3a
20
Endpoint/Common/MapperDto/UserConverter.cs
Normal file
20
Endpoint/Common/MapperDto/UserConverter.cs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
using Mirea.Api.Endpoint.Configuration.Model;
|
||||||
|
using Mirea.Api.Security.Common.Model;
|
||||||
|
|
||||||
|
namespace Mirea.Api.Endpoint.Common.MapperDto;
|
||||||
|
|
||||||
|
public static class UserConverter
|
||||||
|
{
|
||||||
|
public static User ConvertToSecurity(this Admin data) =>
|
||||||
|
new()
|
||||||
|
{
|
||||||
|
Id = 1.ToString(),
|
||||||
|
Email = data.Email,
|
||||||
|
Username = data.Username,
|
||||||
|
PasswordHash = data.PasswordHash,
|
||||||
|
Salt = data.Salt,
|
||||||
|
SecondFactorToken = data.Secret,
|
||||||
|
TwoFactorAuthenticator = data.TwoFactorAuthenticator,
|
||||||
|
OAuthProviders = data.OAuthProviders
|
||||||
|
};
|
||||||
|
}
|
@ -178,17 +178,7 @@ public class AuthController(IOptionsSnapshot<Admin> user, IOptionsSnapshot<Gener
|
|||||||
var tokenResult = await auth.LoginAsync(
|
var tokenResult = await auth.LoginAsync(
|
||||||
GetCookieParams(),
|
GetCookieParams(),
|
||||||
HttpContext,
|
HttpContext,
|
||||||
new User
|
userEntity.ConvertToSecurity(),
|
||||||
{
|
|
||||||
Id = 1.ToString(),
|
|
||||||
Username = userEntity.Username,
|
|
||||||
Email = userEntity.Email,
|
|
||||||
PasswordHash = userEntity.PasswordHash,
|
|
||||||
Salt = userEntity.Salt,
|
|
||||||
TwoFactorAuthenticator = userEntity.TwoFactorAuthenticator,
|
|
||||||
SecondFactorToken = userEntity.Secret,
|
|
||||||
OAuthProviders = userEntity.OAuthProviders
|
|
||||||
},
|
|
||||||
request.Password, request.Username);
|
request.Password, request.Username);
|
||||||
|
|
||||||
return Ok(tokenResult.ConvertToDto());
|
return Ok(tokenResult.ConvertToDto());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user