fix: distinguish invalid share keys from password-protected shares in 401 handling

This commit is contained in:
Tqqk
2026-04-04 21:02:53 +02:00
parent 6952c4811a
commit 440e07aa38
+8 -3
View File
@@ -201,13 +201,18 @@ class Immich {
} }
} }
} else if (res.status === 401) { } else if (res.status === 401) {
// Password authentication required (handles both "Invalid password" and "Password required" from Immich API) // 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 { return {
valid: true, valid: true,
passwordRequired: true passwordRequired: true
} }
} else if (jsonBody?.message === 'Invalid share key') { }
log('Invalid share key ' + key)
} else { } else {
console.log(JSON.stringify(jsonBody)) console.log(JSON.stringify(jsonBody))
} }