jschan - Anonymous imageboard software. Classic look, modern features and feel. Works without JavaScript and supports Tor, I2P, Lokinet, etc.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

43 lines
1.0 KiB

'use strict';
const Permissions = require(__dirname+'/permissions.js')
, PermissionText = require(__dirname+'/permissiontext.js') //todo:combine^
, BigBitfield = require('big-bitfield');
class Permission extends BigBitfield {
constructor(data) {
super(data);
}
static permissionEntries = Object.entries(Permissions)
.filter(e => typeof e[1] === 'number');
static allPermissions = this.permissionEntries
.map(e => e[1]);
toJSON() {
return this.constructor.permissionEntries
.reduce((acc, entry) => {
acc[entry[0]] = {
bit: entry[1],
state: this.get(entry[1]),
label: PermissionText[entry[0]].label,
desc: PermissionText[entry[0]].desc,
title: PermissionText[entry[0]].title,
};
return acc;
}, {});
}
applyInheritance() {
if (this.get(Permissions.ROOT)){ //root gets all perms
this.setAll(this.constructor.allPermissions);
} else if (this.get(Permissions.MANAGE_BOARD_OWNER)) { //BOs and "global staff"
this.setAll(Permissions._MANAGE_BOARD_BITS);
}
}
};
module.exports = Permission;