Files
klz-cables.com/.pnpm-store/v10/files/e8/42bf8e0a118f3d786bdb273f08056717595f2751e7de038cb4b0ae9cd142400638d58528a39bd4ee14cfb1cc7bce10b0f0660770c7bd877de613b450ca5852
Marc Mintel 5397309103
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
fix(products): fix breadcrumbs and product filtering (backport from main)
2026-02-24 16:04:21 +01:00

51 lines
1.5 KiB
Plaintext

import { executeAccess } from '../auth/executeAccess.js';
import { Forbidden } from '../errors/Forbidden.js';
export const checkFileAccess = async ({ collection, filename, req })=>{
if (filename.includes('../') || filename.includes('..\\')) {
throw new Forbidden(req.t);
}
const { config } = collection;
const accessResult = await executeAccess({
data: {
filename
},
isReadingStaticFile: true,
req
}, config.access.read);
if (typeof accessResult === 'object') {
const queryToBuild = {
and: [
{
or: [
{
filename: {
equals: filename
}
}
]
},
accessResult
]
};
if (config.upload.imageSizes) {
config.upload.imageSizes.forEach(({ name })=>{
queryToBuild.and?.[0]?.or?.push({
[`sizes.${name}.filename`]: {
equals: filename
}
});
});
}
const doc = await req.payload.db.findOne({
collection: config.slug,
req,
where: queryToBuild
});
if (!doc) {
throw new Forbidden(req.t);
}
return doc;
}
};
//# sourceMappingURL=checkFileAccess.js.map