From 440e07aa380a525812077cb75a089311619390d6 Mon Sep 17 00:00:00 2001 From: Tqqk <93881136+Tqqk@users.noreply.github.com> Date: Sat, 4 Apr 2026 21:02:53 +0200 Subject: [PATCH] fix: distinguish invalid share keys from password-protected shares in 401 handling --- app/src/immich.ts | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/app/src/immich.ts b/app/src/immich.ts index 0e46dd8..7932671 100644 --- a/app/src/immich.ts +++ b/app/src/immich.ts @@ -201,13 +201,18 @@ class Immich { } } } else if (res.status === 401) { - // Password authentication required (handles both "Invalid password" and "Password required" from Immich API) - return { - valid: true, - passwordRequired: true + // Immich returns 401 for both invalid keys and password-protected shares. + // Check the message to distinguish between the two cases. + if (jsonBody?.message === 'Invalid share key' || jsonBody?.message === 'Invalid share slug') { + // Known invalid key/slug - treat as invalid request + log('Invalid share key ' + key) + } else { + // Default: treat as password required (fail-safe) + return { + valid: true, + passwordRequired: true + } } - } else if (jsonBody?.message === 'Invalid share key') { - log('Invalid share key ' + key) } else { console.log(JSON.stringify(jsonBody)) }