#176 fix slug links with password protection
This commit is contained in:
+8
-7
@@ -14,6 +14,7 @@ import { addResponseHeaders, canDownload, getConfigOption, log } from './functio
|
||||
import render from './render'
|
||||
import { Response } from 'express-serve-static-core'
|
||||
import { respondToInvalidRequest } from './invalidRequestHandler'
|
||||
import { encrypt } from './encrypt'
|
||||
|
||||
class Immich {
|
||||
/**
|
||||
@@ -104,13 +105,13 @@ class Immich {
|
||||
}
|
||||
const link = sharedLinkRes.link
|
||||
|
||||
// Make sure there are some photo/video assets for this link
|
||||
/*
|
||||
if (!link.assets.length) {
|
||||
log('No assets for key ' + request.key)
|
||||
respondToInvalidRequest(res, 404)
|
||||
return
|
||||
} */
|
||||
// If this was a slug link, we need to also store session information for the ID-based key
|
||||
if (request.req.session && !request.req.session[link.key]) {
|
||||
request.req.session[link.key] = encrypt(JSON.stringify({
|
||||
password: request.password,
|
||||
expires: dayjs().add(1, 'hour').format()
|
||||
}))
|
||||
}
|
||||
|
||||
// Everything is ok - output the shared link data
|
||||
|
||||
|
||||
+4
-8
@@ -95,6 +95,10 @@ app.get('/:shareType(share|s)/:key/:mode(download)?', decodeCookie, async (req,
|
||||
* [ROUTE] Receive an unlock request from the password page
|
||||
* Stores a cookie with an encrypted payload which expires in 1 hour.
|
||||
* After that time, the visitor will need to provide the password again.
|
||||
*
|
||||
* The data is encrypted/decrypted on the server as a db-less way of
|
||||
* managing user session data. The data is provided to the server by the
|
||||
* user's browser in its encrypted state.
|
||||
*/
|
||||
app.post('/share/unlock', async (req, res) => {
|
||||
if (req.session && req.body.key) {
|
||||
@@ -125,13 +129,6 @@ app.get('/share/:type(photo|video)/:key/:id/:size?', decodeCookie, async (req, r
|
||||
return
|
||||
}
|
||||
|
||||
/*
|
||||
This was the change made in PR https://github.com/alangrainger/immich-public-proxy/pull/174
|
||||
I have had to remove this because it was preventing password-protected slug albums
|
||||
from working.
|
||||
|
||||
This will be added back in once the slug issue is solved.
|
||||
|
||||
// Validate share link and check password before serving assets
|
||||
// This prevents direct URL access from bypassing password protection
|
||||
// The password is provided from the encrypted session cookie (if set)
|
||||
@@ -153,7 +150,6 @@ app.get('/share/:type(photo|video)/:key/:id/:size?', decodeCookie, async (req, r
|
||||
respondToInvalidRequest(res, 404, 'Asset not found in share')
|
||||
return
|
||||
}
|
||||
*/
|
||||
|
||||
const request = {
|
||||
req,
|
||||
|
||||
Reference in New Issue
Block a user