Added optional alt-inclusion to channel-wide bans.
This commit is contained in:
parent
40c004795b
commit
756c42ceaa
|
|
@ -470,13 +470,27 @@ channelSchema.methods.permCheck = async function (user, perm){
|
||||||
channelSchema.methods.checkBanByUserDoc = async function(userDB){
|
channelSchema.methods.checkBanByUserDoc = async function(userDB){
|
||||||
var foundBan = null;
|
var foundBan = null;
|
||||||
|
|
||||||
this.banList.forEach((ban) => {
|
//this needs to be a for loop for async
|
||||||
if(ban.user != null){
|
//this.banList.forEach((ban) => {
|
||||||
if(ban.user.toString() == userDB._id.toString()){
|
for(banIndex in this.banList){
|
||||||
foundBan = ban;
|
|
||||||
|
if(this.banList[banIndex].user != null){
|
||||||
|
if(this.banList[banIndex].user.toString() == userDB._id.toString()){
|
||||||
|
foundBan = this.banList[banIndex];
|
||||||
|
}
|
||||||
|
|
||||||
|
//If this bans alts are banned
|
||||||
|
if(this.banList[banIndex].banAlts){
|
||||||
|
//Populate the user of the current ban being checked
|
||||||
|
await this.populate(`banList.${banIndex}.user`);
|
||||||
|
|
||||||
|
//If this is an alt of the banned user
|
||||||
|
if(await this.banList[banIndex].user.altCheck(userDB)){
|
||||||
|
foundBan = this.banList[banIndex];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
return foundBan;
|
return foundBan;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -633,6 +633,21 @@ userSchema.methods.changePassword = async function(passChange){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
userSchema.methods.altCheck = async function(userDB){
|
||||||
|
//Found alt flag
|
||||||
|
let foundAlt = false;
|
||||||
|
|
||||||
|
for(alt in this.alts){
|
||||||
|
//If we found a match
|
||||||
|
if(this.alts[alt]._id.toString() == userDB._id.toString()){
|
||||||
|
foundAlt = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//return the results
|
||||||
|
return foundAlt;
|
||||||
|
}
|
||||||
|
|
||||||
userSchema.methods.nuke = async function(pass){
|
userSchema.methods.nuke = async function(pass){
|
||||||
//Check we have a confirmation password
|
//Check we have a confirmation password
|
||||||
if(pass == "" || pass == null){
|
if(pass == "" || pass == null){
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue