forked from unimatrix/web
Separate passive-order mother rights from membership, private boards and electoral authority
This commit is contained in:
parent
95c875d570
commit
cc47a557fd
3 changed files with 15 additions and 4 deletions
|
|
@ -71,6 +71,8 @@ export async function upgradeOriginalCompany(db,keys,user,input){
|
|||
|
||||
// Derived control follows current parent deeds; it never changes membership or title ownership.
|
||||
export async function companyHierarchyControllers(db,id){
|
||||
// The honorary Order has a custom POL deed; never expand its narrow mother rights into company management.
|
||||
if(await db.prepare("SELECT company_id FROM site_company_institutions WHERE company_id=? AND institution_key='order-crysknife'").bind(id).first())return[];
|
||||
if(await entityParent(db,'company',id))return entityControllers(db,'company',id);
|
||||
const users=new Set(),seen=new Set([id]);let current=id;
|
||||
for(let depth=0;depth<32;depth++){
|
||||
|
|
|
|||
6
website/node/passive-order-policy.mjs
Normal file
6
website/node/passive-order-policy.mjs
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
// Reusable institutional deed policy. Capabilities are explicit, never inherited wholesale.
|
||||
export const PASSIVE_ORDER_POLICY=Object.freeze({type:'passive-order',kind:'politics',passive:true,claims:true,privateBoards:true,pvp:false,conquest:false,war:false,electionSeat:false,extraVotes:false,decisions:false});
|
||||
export const CRYSKNIFE_DEED_POLICY=Object.freeze({...PASSIVE_ORDER_POLICY,institution:'order-crysknife',parentOffice:'emperor',leaderFixed:true,parentCapabilities:Object.freeze(['motd.edit','account.view','account.pay'])});
|
||||
export function passiveOrderCapabilities({member=false,localLeader=false,parentOfficeholder=false}={}){
|
||||
return Object.freeze({readBoards:member===true,postBoards:member===true,manageBoards:member===true&&localLeader===true,editMotd:localLeader===true||parentOfficeholder===true,viewAccount:localLeader===true||parentOfficeholder===true,payFromAccount:localLeader===true||parentOfficeholder===true,manageMembers:localLeader===true,manageClaims:localLeader===true,replaceLeader:false,changeParent:false,changePassiveStatus:false,pvp:false,conquest:false,war:false,electionSeat:false,extraVotes:false});
|
||||
}
|
||||
|
|
@ -1,5 +1,3 @@
|
|||
import {companyDeedOperators} from './company-deeds.mjs';
|
||||
import {clanDeedOperators} from './clan-deeds.mjs';
|
||||
// Native forum projections are derived from current organisation records on
|
||||
// every sign-in/identity refresh. Never accept memberships from browser input.
|
||||
export function projectSystemBoardAccess({clans=[],companies=[],userId,inspectAll=false,moderateAll=false}={}){
|
||||
|
|
@ -25,5 +23,6 @@ export async function loadSystemBoardAccess(db,user,{inspectAll=false,moderateAl
|
|||
db.prepare('SELECT c.id,c.name,c.active,c.owner_id,m.user_id,m.clan_role FROM site_clans c JOIN site_clan_members m ON m.clan_id=c.id WHERE m.user_id=? AND c.active=1').bind(user.id).all(),
|
||||
db.companyDeedsEnabled?db.prepare("SELECT c.id,c.name,c.status,c.founded_by,c.ceo_account_id,d.owner_account_id,m.user_id member_user_id FROM corrino_companies c JOIN site_company_deeds d ON d.company_id=c.id LEFT JOIN site_company_members m ON m.company_id=c.id AND m.user_id=? WHERE c.status='active' AND (d.owner_account_id=? OR c.ceo_account_id=? OR m.user_id=?) AND EXISTS(SELECT 1 FROM site_company_members deed_owner_member WHERE deed_owner_member.company_id=c.id AND deed_owner_member.user_id=d.owner_account_id)").bind(user.id,user.id,user.id,user.id).all():db.prepare('SELECT id,name,status,founded_by,ceo_account_id FROM corrino_companies WHERE founded_by=? OR ceo_account_id=?').bind(user.id,user.id).all()
|
||||
]);
|
||||
const projected=projectSystemBoardAccess({clans,companies,userId:user.id,inspectAll,moderateAll}),operators=await clanDeedOperators(db);for(const [id,users]of operators)if(users.includes(user.id)){const existing=projected.organisations.find(o=>o.kind==='clan'&&o.id===id);if(existing)existing.manage=true;else projected.organisations.push({kind:'clan',id,read:true,post:true,manage:true});}for(const org of projected.organisations)if(org.kind==='clan'&&!org.name){const record=await db.prepare('SELECT name FROM site_clans WHERE id=? AND active=1').bind(org.id).first();if(record)org.name=record.name;}const companyOperators=await companyDeedOperators(db);for(const [id,users]of companyOperators)if(users.includes(user.id)){const existing=projected.organisations.find(o=>o.kind==='company'&&o.id===id);if(existing)existing.manage=true;else{const company=await db.prepare("SELECT name FROM corrino_companies WHERE id=? AND status='active'").bind(id).first();if(company)projected.organisations.push({kind:'company',id,name:company.name,read:true,post:true,manage:true});}}return projected;
|
||||
// Parent-deed administration never grants membership in a child's private boards.
|
||||
return projectSystemBoardAccess({clans,companies,userId:user.id,inspectAll,moderateAll});
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue

Staff