fix(security): one settings decoder, and the last creation path

Round-four review follow-ups.

Every reader of app_settings now shares decodeSettingValue. The previous
commit taught the GET handler to decode, which on a legacy SQLite install
made the tab show devtools protection as disabled while
readBooleanSetting — parsing once, getting the string 'false', rejecting
it — left new galleries with it enabled. A decoder used by only some
readers is worse than none, because the UI and the behaviour disagree.
readBooleanSetting, getImageSecurityDefaults, the v1 devtools fallback
and the settings GET all use it now.

Standalone contract conversion covered. contract/conversions.js takes
Path B and inserts its own event row when the contract has no source
quote, so signed standalone contracts were the last path still landing
on the migration-038 column defaults.

Refs #1296
This commit is contained in:
Paul Nothaft
2026-09-05 07:48:41 +02:00
parent 0e560ebb19
commit 0deef2584f
5 changed files with 71 additions and 26 deletions
@@ -229,6 +229,8 @@ async function convertToEvent(contractId, adminId) {
|| (await resolveDefaultEventType());
const eventCols = await db('events').columnInfo();
const { getImageSecurityDefaults, resolveImageSecurityColumns } = require('../../routes/adminEvents/helpers');
const imageSecurityColumns = resolveImageSecurityColumns({}, await getImageSecurityDefaults());
const candidate = {
slug: `contract-${contract.contract_number.toLowerCase()}-${crypto.randomBytes(3).toString('hex')}`,
// Prefer the contract's event_name snapshot (set on the contract
@@ -255,6 +257,11 @@ async function convertToEvent(contractId, adminId) {
quote_id: null,
created_at: new Date(),
updated_at: new Date(),
// #1296 — a signed standalone contract converts straight to a gallery
// here, without going through quoteService, so the global Image Security
// defaults have to be applied on this path too. Not inside a transaction,
// so the global db read is fine.
...imageSecurityColumns,
};
const eventRow = {};
for (const [k, v] of Object.entries(candidate)) {