Fixed vulnerability in changeRankController.js

This commit is contained in:
rainbow napkin 2024-11-24 05:46:15 -05:00
parent 33026a1265
commit 9d401ae6a8
2 changed files with 16 additions and 23 deletions

View file

@ -142,30 +142,10 @@ channelSchema.methods.updateChannelPerms = async function(permissionsMap){
return this.permissions;
}
channelSchema.methods.getChannelRankFromUser = async function(userDB){
}
channelSchema.methods.channelPermCheck = async function(user, perm){
const perms = await permissionSchema.getPerms();
//Set user to anon rank if no rank was found for the given user
if(user == null || user.rank == null){
user ={
rank: "anon"
};
}
//Check if this permission exists
if(this.permissions[perm] != null){
//if so get required rank as a number
requiredRank = permissionModel.rankToNum(this[perm]);
//get the required site-wide rank to override channel perms
requiredOverrideRank = permissionModel.rankToNum(perms.channeOverrides[perm]);
//get user site rank as a number
userRank = user ? permissionModel.rankToNum(user.rank) : 0;
}else{
//if not scream and shout
throw new Error(`Permission check '${perm}' not found!`);
}
}
channelSchema.methods.nuke = async function(confirm){