Skip to content

Commit

Permalink
fix(server/accounts): blacklist some account actions on group accounts
Browse files Browse the repository at this point in the history
  • Loading branch information
thelindat committed Oct 25, 2024
1 parent 9477e3c commit 0ac4169
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions server/accounts/roles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ type OxAccountMetadataRow = OxAccountPermissions & { id?: number; name?: OxAccou

const accountRoles = {} as Record<string, OxAccountPermissions>;

const blacklistedGroupActions = {
addUser: true,
removeUser: true,
manageUser: true,
transferOwnership: true,
manageAccount: true,
closeAccount: true,
} as Record<keyof OxAccountPermissions, true>;

export function CheckRolePermission(roleName: OxAccountRole | null, permission: keyof OxAccountPermissions) {
if (!roleName) return;

Expand All @@ -25,6 +34,8 @@ export async function CanPerformAction(
const groupName = (await SelectAccount(accountId))?.group;

if (groupName) {
if (action in blacklistedGroupActions) return false;

const group = GetGroup(groupName);
const groupRole = group.accountRoles[player.getGroup(groupName)];

Expand Down

0 comments on commit 0ac4169

Please sign in to comment.