Merge the supplied inventory/exchange package into the latest DuneRealms source. Keep community-reward receipts, verified UUID linking, native menus and current website artwork, Dutch naming and account controls. Wire the inventory/sales adapters into the real CP session and verified-link schema, with isolated reads and honest unconfigured states. Preserve lobby/ender separation and Core-owned atomic exchange checkpoints. Validation: website build and 56 tests; 12 inventory/market adapter tests; Core/Essentials and NPC/Terrain/Lobby builds and tests; local browser inspection of the themed inventory, mannequin and History of sales with fictional fixtures. Paper 1.21.8 source only: live 1.21.4 binaries and databases are unchanged.
18 lines
1.6 KiB
JavaScript
18 lines
1.6 KiB
JavaScript
import {randomUUID} from 'node:crypto';
|
|
import {identity} from './auth.mjs';
|
|
import {json} from './game-link.mjs';
|
|
export function createAccountAdmin(db,origin){return async request=>{
|
|
const user=await identity(request,db);if(!user)return json({message:'Sign in first.'},401);if(user.role!=='staff')return json({message:'Staff access required.'},403);
|
|
const path=new URL(request.url).pathname;
|
|
if(request.method==='GET'&&path==='/api/admin/accounts'){
|
|
const {results}=await db.prepare('SELECT a.id,a.username,a.role,a.created_at,l.minecraft_uuid,l.minecraft_name FROM site_accounts a LEFT JOIN site_game_links l ON l.user_id=a.id ORDER BY a.created_at DESC LIMIT 200').all();return json({accounts:results});
|
|
}
|
|
if(request.method!=='POST'||path!=='/api/admin/revoke-sessions')return json({message:'Not found'},404);
|
|
if(request.headers.get('origin')!==origin)return json({message:'Origin rejected'},403);
|
|
let data;try{data=await request.json();}catch{return json({message:'Invalid request'},400);}
|
|
if(typeof data.userId!=='string'||data.userId.length!==36)return json({message:'Invalid account'},400);
|
|
const target=await db.prepare('SELECT id,role FROM site_accounts WHERE id=?').bind(data.userId).first();
|
|
if(!target)return json({message:'Account not found'},404);
|
|
if(target.role==='staff'&&target.id!==user.id)return json({message:'Other staff sessions require operator review.'},403);
|
|
await db.batch([db.prepare('DELETE FROM site_sessions WHERE user_id=?').bind(target.id),db.prepare('INSERT INTO account_audit(id,actor_id,action,details,created_at) VALUES(?,?,?,?,?)').bind(randomUUID(),user.id,'sessions-revoked',target.id,Date.now())]);return json({ok:true});
|
|
};}
|

Staff