Merge pull request #206 from tqqk/fix/invalid-share-key-401

fix: invalid share keys being treated as password-protected shares
This commit is contained in:
Alan Grainger
2026-04-24 10:32:11 +12:00
committed by GitHub
+11 -6
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.
return { // Check the message to distinguish between the two cases.
valid: true, if (jsonBody?.message === 'Invalid share key' || jsonBody?.message === 'Invalid share slug') {
passwordRequired: true // 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 { } else {
console.log(JSON.stringify(jsonBody)) console.log(JSON.stringify(jsonBody))
} }