mirror of
https://github.com/SoPat712/allstarr.git
synced 2026-02-09 23:55:10 -05:00
fix: pass through Jellyfin error responses to client
- Modified PostJsonAsync to return error response body as JSON when available - Updated AuthenticateByName to pass through Jellyfin's actual error response - Clients now see Jellyfin's real error messages instead of generic ones
This commit is contained in:
@@ -1833,9 +1833,17 @@ public class JellyfinController : ControllerBase
|
||||
// Forward to Jellyfin server with client headers
|
||||
var (result, statusCode) = await _proxyService.PostJsonAsync("Users/AuthenticateByName", body, Request.Headers);
|
||||
|
||||
if (result == null)
|
||||
if (statusCode != 200)
|
||||
{
|
||||
_logger.LogWarning("Authentication failed - status {StatusCode}", statusCode);
|
||||
|
||||
// Pass through Jellyfin's error response if available
|
||||
if (result != null)
|
||||
{
|
||||
return StatusCode(statusCode, result.RootElement.GetRawText());
|
||||
}
|
||||
|
||||
// Fallback to generic error if no response body
|
||||
if (statusCode == 401)
|
||||
{
|
||||
return Unauthorized(new { error = "Invalid username or password" });
|
||||
|
||||
@@ -374,6 +374,21 @@ public class JellyfinProxyService
|
||||
var errorContent = await response.Content.ReadAsStringAsync();
|
||||
_logger.LogWarning("❌ SESSION: Jellyfin POST request failed: {StatusCode} for {Url}. Response: {Response}",
|
||||
response.StatusCode, url, errorContent);
|
||||
|
||||
// Try to parse error response as JSON to pass through to client
|
||||
if (!string.IsNullOrWhiteSpace(errorContent))
|
||||
{
|
||||
try
|
||||
{
|
||||
var errorDoc = JsonDocument.Parse(errorContent);
|
||||
return (errorDoc, statusCode);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// Not valid JSON, return null
|
||||
}
|
||||
}
|
||||
|
||||
return (null, statusCode);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user