aboutsummaryrefslogtreecommitdiffstats
path: root/server/src/commands/core
diff options
context:
space:
mode:
authormarzavec <admin@marzavec.com>2020-03-06 16:39:22 +0100
committerGitHub <noreply@github.com>2020-03-06 16:39:22 +0100
commit4e0e269007af349dee969724a8a0128c0ef22dae (patch)
treedaf36b87a9863a798d201242d0bbc68d39cda56d /server/src/commands/core
parentMerge pull request #85 from MinusGix/add_channel_invite (diff)
parentMove most uses of uType filtering to use UAC levels (diff)
downloadhackchat-4e0e269007af349dee969724a8a0128c0ef22dae.tar.gz
hackchat-4e0e269007af349dee969724a8a0128c0ef22dae.zip
Merge pull request #89 from MinusGix/nul_initial2
Added UAC and numeric user levels
Diffstat (limited to 'server/src/commands/core')
-rw-r--r--server/src/commands/core/chat.js7
-rw-r--r--server/src/commands/core/join.js7
2 files changed, 12 insertions, 2 deletions
diff --git a/server/src/commands/core/chat.js b/server/src/commands/core/chat.js
index 6c491b1..01ee256 100644
--- a/server/src/commands/core/chat.js
+++ b/server/src/commands/core/chat.js
@@ -2,6 +2,8 @@
Description: Rebroadcasts any `text` to all clients in a `channel`
*/
+import * as UAC from "../utility/UAC/info";
+
// module support functions
const parseText = (text) => {
// verifies user input is text
@@ -43,11 +45,12 @@ export async function run(core, server, socket, data) {
cmd: 'chat',
nick: socket.nick,
text,
+ level: socket.level
};
- if (socket.uType === 'admin') {
+ if (UAC.isAdmin(socket.level)) {
payload.admin = true;
- } else if (socket.uType === 'mod') {
+ } else if (UAC.isModerator(socket.level)) {
payload.mod = true;
}
diff --git a/server/src/commands/core/join.js b/server/src/commands/core/join.js
index 644470e..eccac6e 100644
--- a/server/src/commands/core/join.js
+++ b/server/src/commands/core/join.js
@@ -2,6 +2,8 @@
Description: Initial entry point, applies `channel` and `nick` to the calling socket
*/
+import * as UAC from "../utility/UAC/info";
+
// module support functions
const crypto = require('crypto');
@@ -20,6 +22,7 @@ export function parseNickname(core, data) {
nick: '',
uType: 'user',
trip: null,
+ level: UAC.levels.user,
};
// seperate nick from password
@@ -36,6 +39,7 @@ export function parseNickname(core, data) {
if (hash(password + core.config.tripSalt) === core.config.adminTrip) {
userInfo.uType = 'admin';
userInfo.trip = 'Admin';
+ userInfo.level = UAC.levels.admin;
} else if (userInfo.nick.toLowerCase() === core.config.adminName.toLowerCase()) {
// they've got the main-admin name while not being an admin
return 'You are not the admin, liar!';
@@ -48,6 +52,7 @@ export function parseNickname(core, data) {
core.config.mods.forEach((mod) => {
if (userInfo.trip === mod.trip) {
userInfo.uType = 'mod';
+ userInfo.level = UAC.levels.moderator;
}
});
@@ -113,6 +118,7 @@ export async function run(core, server, socket, data) {
nick: userInfo.nick,
trip: userInfo.trip || 'null',
hash: userInfo.userHash,
+ level: userInfo.level,
};
// send join announcement and prep online set
@@ -126,6 +132,7 @@ export async function run(core, server, socket, data) {
socket.nick = userInfo.nick;
socket.channel = data.channel;
socket.hash = userInfo.userHash;
+ socket.level = userInfo.level;
if (userInfo.trip !== null) socket.trip = userInfo.trip;
nicks.push(socket.nick);