From 332f7f7bb2e664a4119fe693615dfcc1e1b235e3 Mon Sep 17 00:00:00 2001 From: defnotken Date: Fri, 5 Sep 2025 14:52:03 -0500 Subject: [PATCH] rewriting routs --- .../Controllers/UserController.cs | 13 +++++++------ .../LightlessSyncServices/Discord/MareModule.cs | 9 ++++++++- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/LightlessSyncServer/LightlessSyncAuthService/Controllers/UserController.cs b/LightlessSyncServer/LightlessSyncAuthService/Controllers/UserController.cs index 5d11e47..c84ff49 100644 --- a/LightlessSyncServer/LightlessSyncAuthService/Controllers/UserController.cs +++ b/LightlessSyncServer/LightlessSyncAuthService/Controllers/UserController.cs @@ -7,6 +7,7 @@ using Microsoft.EntityFrameworkCore; namespace LightlessSyncAuthService.Controllers; [Route(LightlessAuth.User)] +[Authorize(Policy = "Internal")] public class UserController : Controller { protected readonly ILogger Logger; @@ -17,8 +18,8 @@ public class UserController : Controller LightlessDbContextFactory = lightlessDbContext; } - [Authorize(Policy = "Internal")] - [HttpPost(LightlessAuth.Ban_Uid)] + [Route(LightlessAuth.Ban_Uid)] + [HttpPost] public async Task MarkForBanUid(string uid) { using var dbContext = await LightlessDbContextFactory.CreateDbContextAsync(); @@ -35,8 +36,8 @@ public class UserController : Controller await dbContext.SaveChangesAsync(); } - [Authorize(Policy = "Internal")] - [HttpPost(LightlessAuth.User_Unban_Uid)] + [Route(LightlessAuth.User_Unban_Uid)] + [HttpPost] public async Task UnBanUserByUid(string uid) { using var dbContext = await LightlessDbContextFactory.CreateDbContextAsync(); @@ -66,8 +67,8 @@ public class UserController : Controller await dbContext.SaveChangesAsync(); } - [Authorize(Policy = "Internal")] - [HttpPost(LightlessAuth.User_Unban_Discord)] + [Route(LightlessAuth.User_Unban_Discord)] + [HttpPost] public async Task UnBanUserByDiscordId(string discordId) { Logger.LogInformation("Unbanning user with discordId: {discordId}", discordId); diff --git a/LightlessSyncServer/LightlessSyncServices/Discord/MareModule.cs b/LightlessSyncServer/LightlessSyncServices/Discord/MareModule.cs index 44113a9..c5cd528 100644 --- a/LightlessSyncServer/LightlessSyncServices/Discord/MareModule.cs +++ b/LightlessSyncServer/LightlessSyncServices/Discord/MareModule.cs @@ -106,7 +106,9 @@ public class LightlessModule : InteractionModuleBase using HttpClient c = new HttpClient(); c.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", _serverTokenGenerator.Token); - + var testUri = new Uri(_lightlessServicesConfiguration.GetValue + (nameof(ServicesConfiguration.MainServerAddress)), "/msgc/sendMessage"); + _logger.LogInformation("UnbanByDiscord:URI:{uri}", testUri); await c.PostAsJsonAsync( new Uri(_lightlessServicesConfiguration.GetValue(nameof(ServicesConfiguration.MainServerAddress)), "/msgc/sendMessage"), new ClientMessage(messageType, message, uid ?? string.Empty) @@ -152,6 +154,7 @@ public class LightlessModule : InteractionModuleBase try { using HttpClient c = new HttpClient(); + c.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", _serverTokenGenerator.Token); await c.PostAsJsonAsync(new Uri(_lightlessServicesConfiguration.GetValue (nameof(ServicesConfiguration.MainServerAddress)), "/user/unbanDiscord"), new { discordId }) @@ -193,6 +196,9 @@ public class LightlessModule : InteractionModuleBase try { using HttpClient c = new HttpClient(); + var testUri = new Uri(_lightlessServicesConfiguration.GetValue + (nameof(ServicesConfiguration.MainServerAddress)), "/user/unbanDiscord"); + _logger.LogInformation("UnbanByDiscord:URI:{uri}", testUri); c.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", _serverTokenGenerator.Token); await c.PostAsJsonAsync(new Uri(_lightlessServicesConfiguration.GetValue (nameof(ServicesConfiguration.MainServerAddress)), "/user/unbanUID"), new { uid }) @@ -234,6 +240,7 @@ public class LightlessModule : InteractionModuleBase try { using HttpClient c = new HttpClient(); + c.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", _serverTokenGenerator.Token); await c.PostAsJsonAsync(new Uri(_lightlessServicesConfiguration.GetValue (nameof(ServicesConfiguration.MainServerAddress)), "/user/ban"), new { uid })