Finished up with toke command list in admin panel.

This commit is contained in:
rainbow napkin 2024-12-12 19:23:11 -05:00
parent 59fe38a5fe
commit 5fe1620c20
7 changed files with 132 additions and 7 deletions

View file

@ -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){