maps icon indicating copy to clipboard operation
maps copied to clipboard

Fix photo viewer in public shared Maps by passing shareToken to Viewer

Open Copilot opened this issue 4 months ago • 0 comments

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: Updated viewPhoto and displayCluster methods
  • PhotoSuggestionsLayer.vue: Updated viewPhoto and displayCluster methods
  • PhotoSuggestionsSidebarTab.vue: Updated onListItemClick method

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.

Copilot avatar Aug 04 '25 22:08 Copilot