From 5fe1620c20c109616223964b026215e62910da47 Mon Sep 17 00:00:00 2001 From: rainbow napkin Date: Thu, 12 Dec 2024 19:23:11 -0500 Subject: [PATCH] Finished up with toke command list in admin panel. --- src/schemas/permissionSchema.js | 9 +- src/views/adminPanel.ejs | 1 + .../partial/adminPanel/tokeCommandList.ejs | 8 +- www/css/adminPanel.css | 31 ++++++- www/css/channel.css | 3 + www/css/global.css | 3 +- www/js/adminPanel.js | 84 ++++++++++++++++++- 7 files changed, 132 insertions(+), 7 deletions(-) diff --git a/src/schemas/permissionSchema.js b/src/schemas/permissionSchema.js index e0ba7c7..9e3782e 100644 --- a/src/schemas/permissionSchema.js +++ b/src/schemas/permissionSchema.js @@ -21,6 +21,7 @@ const {mongoose} = require('mongoose'); //const {userModel} = require('./userSchema'); const userSchema = require('./userSchema'); const channelPermissionSchema = require('./channel/channelPermissionSchema'); +const {errorHandler} = require('../utils/loggerUtils'); //This originally belonged to the permissionSchema, but this avoids circular dependencies. //We could update all references but quite honestly I that would be uglier, this should have a copy too... @@ -119,8 +120,12 @@ permissionSchema.statics.rankToNum = function(rank){ } permissionSchema.statics.permCheck = async function(user, perm){ - const userDB = await userSchema.userModel.findOne({user: user.user}); - return await this.permCheckByUserDoc(userDB, perm); + if(user != null){ + const userDB = await userSchema.userModel.findOne({user: user.user}); + return await this.permCheckByUserDoc(userDB, perm); + }else{ + return await this.permCheckByUserDoc(null, perm); + } } permissionSchema.statics.permCheckByUserDoc = async function(user, perm){ diff --git a/src/views/adminPanel.ejs b/src/views/adminPanel.ejs index f338d09..b052ad0 100644 --- a/src/views/adminPanel.ejs +++ b/src/views/adminPanel.ejs @@ -28,6 +28,7 @@ along with this program. If not, see .--> <%- include('partial/adminPanel/userList', {user, userList, rankEnum}) %> <%- include('partial/adminPanel/permList', {permList, rankEnum}) %> <%- include('partial/adminPanel/userBanList') %> + <%- include('partial/adminPanel/tokeCommandList') %>