diff --git a/src/API/Controllers/Neutrino/NeutrinoController.cs b/src/API/Controllers/Neutrino/NeutrinoController.cs index c25f781..ba7c158 100644 --- a/src/API/Controllers/Neutrino/NeutrinoController.cs +++ b/src/API/Controllers/Neutrino/NeutrinoController.cs @@ -13,10 +13,11 @@ namespace API.Controllers.Neutrino; [ApiController] public class NeutrinoController( INeutrinoAuthorizationService authorizationService, + ILogger logger, IOptions options) : ControllerBase { private readonly NeutrinoOptions _options = options.Value; - + // Photon sends the request with Content-Type: text/plain instead of application/json. [HttpPost("authorize")] public async Task> AuthorizeNeutrinoAsync( @@ -25,7 +26,7 @@ public class NeutrinoController( { if (_options.ValidateSecret && secret != _options.Secret) return Forbid(); - + using var reader = new StreamReader(Request.Body); string rawText = await reader.ReadToEndAsync(ct); @@ -50,18 +51,33 @@ public class NeutrinoController( return Ok( NeutrinoAuthenticateResponse.Failure( AuthenticationResultCode.InvalidParameters)); + + logger.LogInformation( + "Neutrino authorization request received for profile {ProfileId}", + request.ProfileId); var result = await authorizationService.AuthorizeAsync( new AuthorizeNeutrinoCommand( request.ProfileId, request.AccessToken), ct); - + if (!result.Succeeded) + { + logger.LogWarning( + "Neutrino authorization failed for profile {ProfileId}: {Failure}", + request.ProfileId, + result.Failure); return Ok( NeutrinoAuthenticateResponse.Failure( MapFailure(result.Failure))); + } + logger.LogInformation( + "Neutrino authorization succeeded for profile {ProfileId}, nickname {Nickname}", + result.UserId, + result.Nickname); + return Ok( NeutrinoAuthenticateResponse.Success( result.UserId!, @@ -72,4 +88,4 @@ public class NeutrinoController( => failure == NeutrinoAuthorizationFailure.InvalidParameters ? AuthenticationResultCode.InvalidParameters : AuthenticationResultCode.AuthenticationFailedWrongCredentials; -} +} \ No newline at end of file