aboutsummaryrefslogtreecommitdiffstats
path: root/server/src/commands/utility/UAC
diff options
context:
space:
mode:
authormarzavec <admin@marzavec.com>2020-03-06 18:00:30 +0100
committermarzavec <admin@marzavec.com>2020-03-06 18:00:30 +0100
commitda9cbe3dbb799b7b668c895367c7d3778f1d0e16 (patch)
tree026aebaf1c24e82043c658d29afc8cc9b0bce121 /server/src/commands/utility/UAC
parentMerge pull request #89 from MinusGix/nul_initial2 (diff)
downloadhackchat-da9cbe3dbb799b7b668c895367c7d3778f1d0e16.tar.gz
hackchat-da9cbe3dbb799b7b668c895367c7d3778f1d0e16.zip
Minor UAC tweaks
Added an underscore to the uac info lib which prevents the server from attempting to use the file as a command module, allowing removal of the 'info' property and empty 'run' command
Diffstat (limited to 'server/src/commands/utility/UAC')
-rw-r--r--server/src/commands/utility/UAC/_info.js85
-rw-r--r--server/src/commands/utility/UAC/info.js32
2 files changed, 85 insertions, 32 deletions
diff --git a/server/src/commands/utility/UAC/_info.js b/server/src/commands/utility/UAC/_info.js
new file mode 100644
index 0000000..6da85d5
--- /dev/null
+++ b/server/src/commands/utility/UAC/_info.js
@@ -0,0 +1,85 @@
+/**
+ * User Account Control information containing level constants
+ * and simple helper functions used to verify permissions
+ * @property {Object} levels - Defines labels for default permission ranges
+ * @author MinusGix ( https://github.com/MinusGix )
+ * @version v1.0.0
+ * @license WTFPL ( http://www.wtfpl.net/txt/copying/ )
+ */
+
+/**
+ * Object defining labels for default permission ranges
+ * @typedef {Object} levels
+ * @property {number} admin Global administrator range
+ * @property {number} moderator Global moderator range
+ * @property {number} channelOwner Local administrator range
+ * @property {number} channelModerator Local moderator range
+ * @property {number} channelTrusted Local (non-public) channel trusted
+ * @property {number} trustedUser Public channel trusted
+ * @property {number} default Default user level
+ */
+export const levels = {
+ admin: 9999999,
+ moderator: 999999,
+
+ channelOwner: 99999,
+ channelModerator: 9999,
+ channelTrusted: 8999,
+
+ trustedUser: 500,
+ default: 100,
+};
+
+/**
+ * Returns true if target level is equal or greater than the global admin level
+ * @public
+ * @return {boolean}
+ */
+export function isAdmin(level) {
+ return level >= levels.admin;
+}
+
+/**
+ * Returns true if target level is equal or greater than the global moderator level
+ * @public
+ * @return {boolean}
+ */
+export function isModerator(level) {
+ return level >= levels.moderator;
+}
+
+/**
+ * Returns true if target level is equal or greater than the channel owner level
+ * @public
+ * @return {boolean}
+ */
+export function isChannelOwner(level) {
+ return level >= levels.channelOwner;
+}
+
+/**
+ * Returns true if target level is equal or greater than the channel moderator level
+ * @public
+ * @return {boolean}
+ */
+export function isChannelModerator(level) {
+ return level >= levels.channelModerator;
+}
+
+/**
+ * Returns true if target level is equal or greater than the channel trust level
+ * @public
+ * @return {boolean}
+ */
+export function isChannelTrusted(level) {
+ return level >= levels.channelTrusted;
+}
+
+/**
+ * Returns true if target level is equal or greater than a trusted user
+ * @public
+ * @return {boolean}
+ */
+export function isTrustedUser(level) {
+ return level >= levels.trustedUser;
+}
diff --git a/server/src/commands/utility/UAC/info.js b/server/src/commands/utility/UAC/info.js
deleted file mode 100644
index 220e14d..0000000
--- a/server/src/commands/utility/UAC/info.js
+++ /dev/null
@@ -1,32 +0,0 @@
-export const levels = {
- admin : 9999999,
- moderator : 999999,
-
- channelOwner : 99999,
- channelModerator : 9999,
-
- user : 100,
-};
-
-export function isAdmin (level) {
- return level >= levels.admin;
-}
-
-export function isModerator (level) {
- return level >= levels.moderator;
-}
-
-export function isChannelOwner (level) {
- return level >= levels.channelOwner;
-}
-
-export function isChannelModerator (level) {
- return level >= levels.channelModerator;
-}
-
-export async function run (core, server, socket, data) {}
-
-export const info = {
- name: 'uac_info',
- description: 'This module contains information about UAC levels, and minor utility functions.',
-}; \ No newline at end of file