fix(realm): revalidate settings sessions before acquiring a transaction connection
This commit is contained in:
parent
323c4d67f9
commit
c0c2e8b35e
1 changed files with 2 additions and 1 deletions
|
|
@ -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]);
|
||||
|
|
|
|||
Loading…
Reference in a new issue

Staff