using FastEndpoints; using FrameworkBLL.KeyCloak; using FrameworkDAL.DTO.KeyCloak; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace FrameworkSL.Endpoints.KeyCloak { public class KeyCloakAuthenticateUser : BaseEndpoint> { private readonly IKeyCloakBLL _keyCloakBLL; public KeyCloakAuthenticateUser(IKeyCloakBLL keyCloakBLL) { _keyCloakBLL = keyCloakBLL; } public override void Configure() { Post("/Keycloak/KeyCloakAuthenticateUser"); AllowAnonymous(); } public record AuthenticationParameters( [property: FromBody] KeyCloakDTO KeyCloakDTO ); protected override async Task> ExecuteAsync(AuthenticationParameters User, LoginDTO LoginDTO, CancellationToken CancellationToken) { try { string Result = await _keyCloakBLL.KeyCloakAuthenticateUser(User.KeyCloakDTO); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(Result, CacheKeyLevel.NOT_REQUIRED, LoginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.NOT_REQUIRED, LoginDTO, ex.Message, 500); } } } }