From c0c2e8b35ec7ddcc705e23ad4eec3b88acad06ba Mon Sep 17 00:00:00 2001 From: unimatrix Date: Tue, 17 Nov 2026 20:01:24 +0000 Subject: [PATCH] fix(realm): revalidate settings sessions before acquiring a transaction connection --- website/node/organisation-settings-route.mjs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/website/node/organisation-settings-route.mjs b/website/node/organisation-settings-route.mjs index 3aeb52a9..9922ba05 100644 --- a/website/node/organisation-settings-route.mjs +++ b/website/node/organisation-settings-route.mjs @@ -15,8 +15,9 @@ export function createOrganisationSettingsRoute(db,{origin='https://cp.dunerealm if(request.method==='POST'&&request.headers.get('origin')!==origin)return reply({message:'Request origin rejected.'},403); try{ let input;if(request.method==='POST'){const text=await request.text();if(text.length>6000)throw failure('Settings request too large.',413);try{input=JSON.parse(text);}catch{throw failure('Invalid settings.',400);}if(!input||!['motd','identity'].includes(input.action)||!Number.isSafeInteger(input.revision)||input.revision<0)throw failure('Refresh and review the current settings.',400);} + // Revalidate before acquiring a transaction connection; authentication uses the same pool. + const fresh=await authenticate(request);if(fresh?.id!==user.id||!(await access(fresh)).nodes.includes('web.menu.game'))throw failure('Your session changed.',403); return await db.transaction(async tx=>{ - const fresh=await authenticate(request);if(fresh?.id!==user.id)throw failure('Your session changed.',403); let organisation; if(kind==='company'){ organisation=await tx.first("SELECT id,name,description,updated_at,founded_by,ceo_account_id FROM corrino_companies WHERE id=? AND status IN ('active','pending') FOR UPDATE",[id]);