Report active migration status and clarify staff assignment controls

This commit is contained in:
unimatrixgit 2026-11-15 03:02:19 +01:00
commit 0044bba0f3
3 changed files with 117 additions and 16 deletions

View file

@ -52,8 +52,9 @@ export function createCitizenDirectory(db,{authenticate=identity,authorize=can,c
if(request.method!=='GET')return reply({message:'This directory endpoint is read-only.'},405);
const actor=await authenticate(request,db);if(!actor)return reply({message:'Sign in first.'},401);
if(!await authorize(db,actor,'web.accounts.view'))return reply({message:'Account directory permission required.'},403);
const assignmentMode=db.organisationAccessEnabled?'active':'preparing';
const url=new URL(request.url);let filter;try{filter=directoryFilters(url,clock());}catch(e){return reply({message:e.message},400);}
if(url.pathname==='/api/admin/citizens/catalogue')return reply({departments:filter.context==='staff'?ORGANISATION:[],roles:Object.fromEntries(Object.entries(ASSIGNMENT_ROLES).filter(([key])=>STAFF_SCOPE_TYPES.includes(key)===(filter.context==='staff'))),assignmentMode:'preparing',permissionsChanged:false});
if(url.pathname==='/api/admin/citizens/catalogue')return reply({departments:filter.context==='staff'?ORGANISATION:[],roles:Object.fromEntries(Object.entries(ASSIGNMENT_ROLES).filter(([key])=>STAFF_SCOPE_TYPES.includes(key)===(filter.context==='staff'))),assignmentMode,permissionsChanged:false});
const match=url.pathname.match(/^\/api\/admin\/citizens\/([0-9a-f-]{36})$/i);
if(match){
// Staff managers may open a human candidate before their first appointment.
@ -68,11 +69,11 @@ export function createCitizenDirectory(db,{authenticate=identity,authorize=can,c
const {results}=await db.prepare('SELECT source_name,source_ref,imported_at FROM staff_source_members WHERE user_id=? ORDER BY source_key').bind(row.id).all();
account.staffSources=results.map(s=>({name:s.source_name,reference:s.source_ref,importedAt:Number(s.imported_at)}));
}
return reply({account,context:filter.context,assignmentMode:'preparing',permissionsChanged:false});
return reply({account,context:filter.context,assignmentMode,permissionsChanged:false});
}
if(url.pathname!=='/api/admin/citizens')return reply({message:'Not found.'},404);
const {results}=await db.prepare(`SELECT ${fields} FROM site_accounts a${filter.where} ORDER BY a.username,a.id LIMIT ? OFFSET ?`).bind(...filter.values,26,(filter.page-1)*25).all();
const rows=results.slice(0,25),current=await assignments(rows.map(a=>a.id),filter.context);
return reply({accounts:rows.map(row=>({...project(row),assignments:current.filter(a=>a.user_id===row.id).map(assignmentLabel)})),page:filter.page,pageSize:25,hasMore:results.length>25,context:filter.context,assignmentMode:'preparing'});
return reply({accounts:rows.map(row=>({...project(row),assignments:current.filter(a=>a.user_id===row.id).map(assignmentLabel)})),page:filter.page,pageSize:25,hasMore:results.length>25,context:filter.context,assignmentMode});
};
}

View file

@ -240,6 +240,96 @@
"label": "All WorldGuard tools",
"source": "Approved plugin wildcard: network administrator only",
"highRisk": true
},
{
"node": "dune.items.give",
"label": "Issue registered custom items",
"source": "DuneRealms central registered permission catalogue",
"highRisk": true
},
{
"node": "dune.staff.ban.local",
"label": "Ban from one server",
"source": "DuneRealms central registered permission catalogue",
"highRisk": true
},
{
"node": "dune.staff.ban.network",
"label": "Ban from the network",
"source": "DuneRealms central registered permission catalogue",
"highRisk": true
},
{
"node": "dune.staff.history",
"label": "View punishment history",
"source": "DuneRealms central registered permission catalogue",
"highRisk": true
},
{
"node": "dune.staff.kick",
"label": "Kick players",
"source": "DuneRealms central registered permission catalogue",
"highRisk": true
},
{
"node": "dune.staff.mute",
"label": "Mute players",
"source": "DuneRealms central registered permission catalogue",
"highRisk": true
},
{
"node": "dune.staff.open",
"label": "Open staff GUI",
"source": "DuneRealms central registered permission catalogue",
"highRisk": true
},
{
"node": "dune.staff.warn",
"label": "Warn players",
"source": "DuneRealms central registered permission catalogue",
"highRisk": true
},
{
"node": "duneess.exchange",
"label": "Exchange shop",
"source": "DuneRealms central registered permission catalogue",
"highRisk": false
},
{
"node": "duneess.shops.use",
"label": "Use NPC shops",
"source": "DuneRealms central registered permission catalogue",
"highRisk": false
},
{
"node": "duneess.tokens.buy",
"label": "Buy guild tokens",
"source": "DuneRealms central registered permission catalogue",
"highRisk": false
},
{
"node": "duneess.travel",
"label": "Guild travel",
"source": "DuneRealms central registered permission catalogue",
"highRisk": false
},
{
"node": "dunelobby.admin",
"label": "Lobby administration",
"source": "DuneRealms central registered permission catalogue",
"highRisk": true
},
{
"node": "dunelobby.build",
"label": "Build in protected lobby",
"source": "DuneRealms central registered permission catalogue",
"highRisk": true
},
{
"node": "dunelobby.visit",
"label": "Visit lobby",
"source": "DuneRealms central registered permission catalogue",
"highRisk": false
}
],
"networkAdministratorRoles": [

View file

@ -72,7 +72,7 @@ export function createOrganisationManagement(db,{origin='https://cp.dunerealms.c
const policies=await tx.query('SELECT scope_type,scope_key,role_key,permissions_json,version FROM org_role_policies',[]);
const principal=await tx.first('SELECT principal_kind FROM org_control_principals WHERE user_id=?',[userId]);
return effectiveOrganisationAccess({assignments,policies,registry:NODES,principalKind:principal?.principal_kind,now});
});return reply(result);
});return reply({...result,enforcement:db.organisationAccessEnabled?'active':'preparing'});
}
if(url.pathname.endsWith('/activity')){
const context=url.searchParams.get('context')||'users';if(!['users','staff'].includes(context))return reply({message:'Invalid context.'},400);