From 5cc6b0aeb9939faabe99a29d57ed854dd3111a8b Mon Sep 17 00:00:00 2001 From: Hermanus Engelbrecht Date: Sat, 22 Feb 2025 20:52:00 +0100 Subject: [PATCH] feat(component and api): adding emby connect authentication with local account linking Updated authentication flow to handle local account linking #943 --- server/api/jellyfin.ts | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/server/api/jellyfin.ts b/server/api/jellyfin.ts index 2ac97236..7ce23e3f 100644 --- a/server/api/jellyfin.ts +++ b/server/api/jellyfin.ts @@ -187,6 +187,14 @@ class JellyfinAPI extends ExternalAPI { if (e.cause.status === 401) { throw new ApiError(e.cause.status, ApiErrorCode.InvalidCredentials); } + } + + try { + return await authenticate(false); + } catch (e) { + if (e.cause.status === 401) { + throw new ApiError(e.cause.status, ApiErrorCode.InvalidCredentials); + } logger.error( 'Something went wrong while authenticating with the Jellyfin server', @@ -196,24 +204,8 @@ class JellyfinAPI extends ExternalAPI { ip: ClientIP, } ); - } - try { - return await authenticate(false); - } catch (e) { - if (e.cause.status === 401) { - throw new ApiError(e.cause.status, ApiErrorCode.InvalidCredentials); - } else { - logger.error( - 'Something went wrong while authenticating with the Jellyfin server', - { - label: 'Jellyfin API', - error: e.cause.message ?? e.cause.statusText, - ip: ClientIP, - } - ); - throw new ApiError(e.cause.status, ApiErrorCode.Unknown); - } + throw new ApiError(e.cause.status, ApiErrorCode.Unknown); } }