MC/website/node/official-account.mjs
2026-11-27 23:43:05 +00:00

11 lines
1.2 KiB
JavaScript

// Existing verified identities. Display names and client input never establish this link.
export const OFFICIAL_ACCOUNT=Object.freeze({
id:'2c281bc7-c352-4d9a-b94c-fa13eee1157d',username:'dunerealms',
ownerId:'f3ffda37-01e4-41ea-b89d-fbeda82e453e',
minecraftUuid:'00000000-0000-0000-0009-01f09764757f'
});
export async function organisationSubject(reader,userId,{lock=false}={}){
if(userId!==OFFICIAL_ACCOUNT.id)return {userId,alias:false};
const rows=await reader.query("SELECT x.user_id FROM org_control_principals x JOIN site_accounts a ON a.id=x.user_id JOIN site_game_links l ON l.user_id=a.id JOIN org_control_principals p ON p.user_id=? JOIN site_accounts owner ON owner.id=p.user_id WHERE x.user_id=? AND x.principal_kind='owner_alias' AND x.created_by=? AND a.username='dunerealms' AND a.role='official_account' AND a.password_hash NOT LIKE '!%' AND l.minecraft_uuid=? AND p.principal_kind='owner' AND owner.username='unimatrix999' AND owner.password_hash NOT LIKE '!%'"+(lock?' FOR SHARE':''),[OFFICIAL_ACCOUNT.ownerId,userId,OFFICIAL_ACCOUNT.ownerId,OFFICIAL_ACCOUNT.minecraftUuid]);
return rows.length?{userId:OFFICIAL_ACCOUNT.ownerId,alias:true}:{userId,alias:false};
}