Fix photo viewer in public shared Maps by passing shareToken to Viewer
When viewing photos on a publicly shared Maps instance, clicking on photo previews would fail with 401 Unauthorized errors:
GET https://domain.de/index.php/apps/files/api/v1/views 401 (Unauthorized)
PROPFIND https://domain.de/remote.php/dav/files/undefined/photo.JPG 401 (Unauthorized)
The issue occurred because the Viewer component was being called without the public share context, causing it to attempt file access using standard user-based DAV paths instead of public share paths.
Root Cause:
The OCA.Viewer.open() calls in photo-related components were not passing the share token when in a public share context. This resulted in the Viewer trying to construct URLs like remote.php/dav/files/undefined/... instead of the correct public share format public.php/dav/files/{token}/....
Solution:
Modified the photo viewer methods to detect public share context using getToken() and pass the shareToken parameter to the Viewer when appropriate:
const token = getToken()
if (token) {
// For public shares, pass the share token to the Viewer
OCA.Viewer.open({
path: photo.path,
list: [photo],
shareToken: token
})
} else {
// For logged-in users, use the standard approach
OCA.Viewer.open({ path: photo.path, list: [photo] })
}
Components Updated:
PhotosLayer.vue: UpdatedviewPhotoanddisplayClustermethodsPhotoSuggestionsLayer.vue: UpdatedviewPhotoanddisplayClustermethodsPhotoSuggestionsSidebarTab.vue: UpdatedonListItemClickmethod
This fix follows the same pattern already used successfully in the getPreviewUrl method for photo thumbnails, ensuring consistency across the codebase. The behavior for logged-in users remains unchanged.
Fixes #1436.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.