fix client
This commit is contained in:
parent
55d8d0a1c2
commit
60589ba45f
@ -7,8 +7,17 @@ namespace Suspectus.Gandalf.Bridgekeeper.Api.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("api/[controller]")]
|
||||
public class AuthController(IPalantirClient client) : ControllerBase
|
||||
public class AuthController : ControllerBase
|
||||
{
|
||||
private readonly IPalantirClient _client;
|
||||
private readonly IPalantirAuthClient _authClient;
|
||||
|
||||
public AuthController(IPalantirClient client, IPalantirAuthClient authClient)
|
||||
{
|
||||
_client = client;
|
||||
_authClient = authClient;
|
||||
}
|
||||
|
||||
[HttpGet("[action]")]
|
||||
public async Task<IActionResult> Check()
|
||||
{
|
||||
@ -18,7 +27,7 @@ public class AuthController(IPalantirClient client) : ControllerBase
|
||||
[HttpPost("[action]")]
|
||||
public async Task<IActionResult> Login([FromBody] LoginCommand loginCommand)
|
||||
{
|
||||
var validationResult = await client.Auth.ValidateCredentials(new ValidateCredentialsCommand { Password = loginCommand.Password, UsernameOrEmail = loginCommand.UsernameOrEmail });
|
||||
var validationResult = await _client.Auth.ValidateCredentials(new ValidateCredentialsCommand { Password = loginCommand.Password, UsernameOrEmail = loginCommand.UsernameOrEmail });
|
||||
|
||||
return validationResult.Match<IActionResult>(valid =>
|
||||
{
|
||||
|
||||
@ -2,11 +2,10 @@ using Suspectus.Gandalf.Palantir.Client.Extensions;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
builder.Services.AddPalantirClient();
|
||||
builder.Services.AddControllers();
|
||||
builder.Services.AddOpenApi();
|
||||
|
||||
builder.Services.AddPalantirClient();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
if (app.Environment.IsDevelopment())
|
||||
|
||||
@ -6,8 +6,15 @@ public static class ServiceCollectionExtensions
|
||||
{
|
||||
public static IServiceCollection AddPalantirClient(this IServiceCollection services)
|
||||
{
|
||||
services.AddHttpClient<IPalantirAuthClient, PalantirAuthClient>(opt => opt.BaseAddress = new Uri("https://localhost:7269/")); // TODO: WTF BRO WHY YOU DONT WORK
|
||||
services.AddScoped<IPalantirAuthClient, PalantirAuthClient>();
|
||||
services.AddHttpClient<IPalantirAuthClient, PalantirAuthClient>(opt =>
|
||||
{
|
||||
opt.BaseAddress = new Uri("https://localhost:7269/api/auth/");
|
||||
})
|
||||
.ConfigurePrimaryHttpMessageHandler(() => new HttpClientHandler //TODO: Remove this in production
|
||||
{
|
||||
ServerCertificateCustomValidationCallback =
|
||||
HttpClientHandler.DangerousAcceptAnyServerCertificateValidator
|
||||
});
|
||||
services.AddScoped<IPalantirClient, PalantirClient>();
|
||||
return services;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user